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

Doesn't support configurable intervals (and other watch options). #4

Open
iMartyn opened this issue Apr 3, 2020 · 5 comments
Open

Comments

@iMartyn
Copy link

iMartyn commented Apr 3, 2020

Looking at the code, this implementation of watch only has an interval of 1 second. For commands that are heavy on resources, that's too frequent.

In normal (gnu?) watch you can set an interval and other options :

/usr/bin/watch --help

Usage:
 watch [options] command

Options:
  -b, --beep             beep if command has a non-zero exit
  -c, --color            interpret ANSI color and style sequences
  -d, --differences[=<permanent>]
                         highlight changes between updates
  -e, --errexit          exit if command has a non-zero exit
  -g, --chgexit          exit when output from command changes
  -n, --interval <secs>  seconds to wait between updates
  -p, --precise          attempt run command in precise intervals
  -t, --no-title         turn off header
  -x, --exec             pass command to exec instead of "sh -c"

 -h, --help     display this help and exit
 -v, --version  output version information and exit

For more details see watch(1).

It would be good to have those implemented. Also, amusingly watch --help in this implementation tries to watch a command --help. The experienced unix admin knows that to pass arguments to apps they have to push a -- separator, so watch -c -n30 -- ls -c but if you do this, be sure to document :-)

@antonmedv
Copy link
Owner

What about watch 30s command name?

@iMartyn
Copy link
Author

iMartyn commented Apr 3, 2020

I'd recommend using flag or cobra flags to try and match the options in the current watch command as you'll get more adoption if it's a drop-in replacement. Then you can also map WATCH_COMMAND to -x.

@ghostsquad
Copy link

I just found this, and I'm interested in the same thing. I could submit a PR for this if you like?

@antonmedv
Copy link
Owner

Okay 👌

@ghostsquad
Copy link

I'll submit a PR to introduce optional flags, and include the interval flag. That should at least be enough to then get started on adding other flags

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

Successfully merging a pull request may close this issue.

3 participants