shaman icon indicating copy to clipboard operation
shaman copied to clipboard

Standardize verbosity

Open HalosGhost opened this issue 10 years ago • 10 comments

At the moment, if a user calls shaman with the -v or --verbose flag, the only difference will be that, if the cache is not found, an error will be printed.

The behavior for verbosity should be extended beyond just cache location, and should have well-defined and understandable behavior.

I am considering the following:

  • -v will print all non-fatal error messages along with the string from the format specifier.
  • -vv will print all status information throughout the execution (e.g., this would include setting curl_easy's verbosity flag).

Does anyone feel that it would be helpful to add another level of verbosity? If so, what should it include?

Does it make sense to add a corrolary flag -q|--quiet that will silence everything (e.g., it would not be too difficult to have shaman return part of the weather code to indicate some information about the current condition while printing nothing)?

HalosGhost avatar Jul 07 '14 19:07 HalosGhost

For -q|--quiet flag, I think a silent fail with an error code should be nice when shaman is run in scripts and such. But -v and -vv for warning/error and notice/info is fine.

fengshaun avatar Jul 08 '14 21:07 fengshaun

And, you think it would be helpful for the status code to reflect (in a general sense) what the weather conditions are?

HalosGhost avatar Jul 08 '14 22:07 HalosGhost

Default behaviour should be quiet (no need for a -q|--quiet switch).

-v|--verbose and -vv|--moar-verbose would be sufficient, IMO. Keep it simple.

jasonwryan avatar Jul 08 '14 22:07 jasonwryan

@jasonwryan, to clarify, the -q|--quiet flag I was considering would silence all output (it would override the format specifier) and only return a status code which would refer to a part of the weather code. Does that make any sense at all?

HalosGhost avatar Jul 08 '14 22:07 HalosGhost

Oh, I see. Can you describe a use case? I'm sure I am missing something, but I can't think of one.

jasonwryan avatar Jul 08 '14 22:07 jasonwryan

The only thing I can think of off the top of my head would be using it in a status tray. Consider the following pseudo-code:

case "$(shaman -q -l'Saint Paul,US';echo $?)" in
    2) # display clear skies icon;;
    8) # display rain icon;;
    *) # etc;;
esac

Again, I'm unsure of how useful this would actually be in the wild, but I can imagine some use for it. Thoughts?

HalosGhost avatar Jul 08 '14 23:07 HalosGhost

That makes perfect sense: I wasn't clear on how the weather status codes work. Nice.

jasonwryan avatar Jul 08 '14 23:07 jasonwryan

Okay, I have added a preliminary -q|--quiet flag that sets the return code to a value which is interpretable by use of the man page.

Moving forward, I am planning on both -q|--quiet and -v|--verbose to be incremental (you can specify them multiple times to make it clear how silent or how verbose you wish the output to be).

This will mean, for example, -q will silence only the formatted output, -qq will silence everything. Similarly, -v will print non-fatal errors/warnings where they otherwise would be suppressed (and -vv will print all status messages). As a result, -qv (and -qvv) would actually make sense (it will print all non-fatal errors/warnings, but will not print the formatted output and instead set shaman's return code to the corresponding value). However, combining -qq with any number of vs will make no sense (since qq is planned to silence all output).

HalosGhost avatar Jul 09 '14 00:07 HalosGhost

now that I think about it, do you really need verbose/quiet? Output the weather conditions according to format with a return code of 0. If ship goes sideways, then output error to stderr with a return code != 0. No need to make it complicated. Maybe add a --debug flag for debugging purposes which would write out every step or something.

edit: you can use -1 return as error if you have positive numbers for icon codes(?).

fengshaun avatar Jul 10 '14 00:07 fengshaun

The --verbose flag(s) are essentially debug flags. I would not mind changing it to that. But, --quiet is really meant for use in scripts (by manipulating the status code).

HalosGhost avatar Jul 10 '14 01:07 HalosGhost