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

Using banner disables usage & synopsis #89

Open
tiennou opened this issue Nov 8, 2017 · 4 comments
Open

Using banner disables usage & synopsis #89

tiennou opened this issue Nov 8, 2017 · 4 comments

Comments

@tiennou
Copy link

tiennou commented Nov 8, 2017

Example option block :

opts = Trollop::options do
  version 0.1

  usage "foo|bar"
  synopsis "Reticulate splines"

  banner "Recognized options: "
  opt :dry_run, "Don't do anything", short: "-n"
end

Output when passed --help is :

Recognized options: 
  -n, --dry-run    Don't do anything
  -v, --version    Print version and exit
  -h, --help       Show this message

If I comment just the banner line, I get this :

Usage: test foo|bar
Reticulate splines

0.1
Options:
  -n, --dry-run    Don't do anything
  -v, --version    Print version and exit
  -h, --help       Show this message

Additionally, I get warnings (the shebang line is #!/usr/bin/env ruby -W) depending on whether the usage or synopsis lines are comment out :

$gem-path/trollop-2.1.2/lib/trollop.rb:480: warning: instance variable @usage not initialized
$gem-path/trollop-2.1.2/lib/trollop.rb:481: warning: instance variable @synopsis not initialized
@nanobowers
Copy link
Collaborator

@tiennou I agree that the behavior is not intiutive, however it is documented in the Wiki with some examples:
https://github.com/ManageIQ/trollop/wiki/Banner%2C-Synopsis-and-Version

The warnings should be fixed in PR #80

@kbrock
Copy link
Member

kbrock commented Dec 4, 2017

Is there a suggestion on how it should behave?

@tiennou
Copy link
Author

tiennou commented Dec 5, 2017

I suggest that banner, being an alias of text, shouldn't prevent usage & synopsis from working, so we get to have both nice, automated synopsises as well as free-form text. Would that be acceptable ?

From a backward-compatibility POV, I don't think it would have a big impact, seeing as it's either banner/text OR usage/synopsis, you would have skimmed over the former as soon as you were to use the latter.

@kbrock
Copy link
Member

kbrock commented Mar 6, 2018

I'm mixed on this one.

I had thought that banner is used to define your own header.
If you didn't provide it, the system would create one using version, usage and synopsis

@Fryguy you see any downside to always producing header information even when banner is added.

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

No branches or pull requests

4 participants