Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viddy as a importable package #54

Open
anvial opened this issue Jun 23, 2022 · 15 comments
Open

Viddy as a importable package #54

anvial opened this issue Jun 23, 2022 · 15 comments

Comments

@anvial
Copy link
Contributor

anvial commented Jun 23, 2022

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.

@sachaos
Copy link
Owner

sachaos commented Jun 23, 2022

@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?

@anvial
Copy link
Contributor Author

anvial commented Jun 23, 2022

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?

@sachaos
Copy link
Owner

sachaos commented Jun 24, 2022

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.

@anvial
Copy link
Contributor Author

anvial commented Jun 24, 2022

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
}

@anvial
Copy link
Contributor Author

anvial commented Jul 7, 2022

Hi, @sachaos

I hope you're doing well.

Any updates on this issue?

If any help is needed, just ping me.

@sachaos
Copy link
Owner

sachaos commented Jul 8, 2022

@anvial Hi.

I'm refactoring viddy now.
Please wait for a while. 🙏

@anvial
Copy link
Contributor Author

anvial commented Jul 8, 2022

@sachaos,

no worries, thank you for your work!
I'll be in touch if needed.

@anvial
Copy link
Contributor Author

anvial commented Aug 29, 2022

Hi @sachaos,

I hope you are doing well.

Any updates on this issue?

@gedw99
Copy link

gedw99 commented Sep 14, 2022

This sounds very useful for many projects.

I am wondering if the TUI would need to change or is it generic enough to cope ?

@gedw99
Copy link

gedw99 commented Sep 14, 2022

@gedw99
Copy link

gedw99 commented Sep 14, 2022

Ah it looks like it was forked and done here: juju/viddy@master...anvial:viddy:master

@anvial great work !!

I guess one day it will get merged ?

@sachaos
Copy link
Owner

sachaos commented Sep 14, 2022

@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.

@anvial
Copy link
Contributor Author

anvial commented Sep 15, 2022

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.

@gedw99
Copy link

gedw99 commented Sep 15, 2022

Great news.. thanks @anvial for responding .

@anvial
Copy link
Contributor Author

anvial commented Sep 15, 2022

I've prepared a draft PR: #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').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants