viddy
viddy copied to clipboard
Viddy as a importable package
Hi,
First of all, thx for the excellent watcher alternative.
Are any plans to make the viddy importable go package? To use it as a watch mode implementation in other projects.
@anvial Thank you. Interesting issue. But I don't have any idea to how abstract viddy as package. What is the input and output.
Do you have any use case of the viddy package?
Let's take any command that we wish to watch: any-command
Usually, we do the following: watch (or viddy) -n 1s any-command --some-flags
But what if we wish to integrate watcher functionality inside any-command
: any-command --watch 1s
To implement this, we need to import NewViddy()
from the Viddy package.
It will be nice to provide NewPreconfiguedViddy()
with incapsulation of config generation not to bring 'viper' and other dependencies into the origin project.
Make sense?
I see.
So the package users can construct viddy by like NewViddy("any-command", "args")
.
And interact with viddy by the method of the object.
Is this correct?
I'm refactoring viddy now. I would like to do that with considering that usage.
Yes, almost
I see it as an implementation inside --watch
flag behavior of any-command
.
So, for Viddy any-command
is also a part of args
Smth like this:
import (
"github.com/sachaos/viddy"
)
func RunAnyCommand() error {
...
if watchFlag != 0 {
anyCommandArgs, watchValue := anyCommandArgsWithoutWatch(os.Args)
// Prepare Viddy args
viddyArgs := append([]string{"--no-title", "--differences", "--interval", watchValue}, anyCommandArgs...)
// Define tview styles and launch preconfigured Viddy watcher
app := viddy.NewPreconfiguredViddy(viddyArgs)
if err := app.Run(); err != nil {
return err
}
} else {
...
}
return nil
}
Hi, @sachaos
I hope you're doing well.
Any updates on this issue?
If any help is needed, just ping me.
@anvial Hi.
I'm refactoring viddy now. Please wait for a while. :pray:
@sachaos,
no worries, thank you for your work! I'll be in touch if needed.
Hi @sachaos,
I hope you are doing well.
Any updates on this issue?
This sounds very useful for many projects.
I am wondering if the TUI would need to change or is it generic enough to cope ?
Is this the branch ?
https://github.com/sachaos/viddy/commits/feature/refactoring-viddy
Ah it looks like it was forked and done here: https://github.com/juju/viddy/compare/master...anvial:viddy:master
@anvial great work !!
I guess one day it will get merged ?
@anvial @gedw99 Sorry I was too busy to continue working this issue. juju/viddy is great! Thanks for your work. I would like to merge this when the PR submitted.
Hi, @gedw99 , @sachaos,
I'm with pleasure prepare the PR. We also wish to use the main Viddy repo, if this functionality will be added.
PS: We also have small suggestions in UI (border menu), and hotkeys map.
Great news.. thanks @anvial for responding .
I've prepared a draft PR: https://github.com/sachaos/viddy/pull/77
waiting for feedback and discussion because to have the same flexibility in Viddy config that there is now in main.go
, we need to do more methods public (like viddy.NewConfig
and 'conf.Theme').