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

Feature/silent and verbose #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

klmanion
Copy link
Contributor

@klmanion klmanion commented Jun 9, 2017

To make ghwd able to be incorporated inside other scripts I added a -r, -s, and -v option. -r is return only mode, and only returns the URL that would have been opened and exits; this is for use in scripts that might want to do other operations than opening the URL. The -s option is the silent option, which silences all output, and is the flag most scripts would want to use to best incorporate ghwd. Each occurrence of a -v flag increments the verbosity variable so that there can be varying levels of verbosity in the future, e.g., "ghwd -vvv" could reveal debug information. The variable defaults to 1, and therefore causes ghwd to function exactly as it does now, outputting the URL before opening it.

I also noticed some echo statements that were reporting errors were not redirected to stderr, so fixed that. And changed the () to {} on ln. 93, because the parenthesis create a subshell, which is the shell exited with exit status 1 by the exit command—in other words, when ghwd can't find an appropriate opener and wants to tell the user that it didn't anticipate their operating system, it does so in a subshell and exits from that subshell with exit status 1, then exits from the actual ghwd shell with exit status 0, even though an error occured.

I'll be happy to write a manpage and update the README with usage information pertaining to these new options once I know what you think of them :)

note: this update will allow @stour to test his added functionality from #20, since now ghwd will be able to just return the URLs.

test cases

ghwd -v
>https://github.com/klmanion/ghwd/tree/feature/silent-and-verbose/bin
>opens URL

ghwd
[same as above]

ghwd -s
>opens URL

ghwd -r
>https://github.com/klmanion/ghwd/tree/feature/silent-and-verbose/bin

@klmanion
Copy link
Contributor Author

Just added commit 1648f25, which adds a manpage and updates the read me with usage information for -r, -s, and -v.

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 this pull request may close these issues.

1 participant