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

Showing "short usage" unless "--help" is provided #83

Closed
DannyBen opened this issue Feb 6, 2018 · 4 comments
Closed

Showing "short usage" unless "--help" is provided #83

DannyBen opened this issue Feb 6, 2018 · 4 comments

Comments

@DannyBen
Copy link

DannyBen commented Feb 6, 2018

Ok, so this Clamp library is gorgeous. I love it, and it had me at "subcommand".

I am used to command line apps showing only a short "usage" pattern whenever they are executed without any argument, and only show the longer help when --help is provided.

With clamp, I see full help even without asking for it with --help.

Is there a way to change this behavior?

I am expecting to only see something like this:

$ ruby test.rb
Usage:
    test.rb [OPTIONS] SUBCOMMAND [ARG] ...

$ _
@mdub
Copy link
Owner

mdub commented Feb 15, 2018

Thanks for the kind words.

I can kind of see what you mean. If you miss a required option or parameter, Clamp emits a short message:

$ ./examples/word 
ERROR: parameter 'WORD': no value provided

See: 'word --help'

So, it might make sense to do something similar for missing subcommands:

$ ./examples/gitdown 
ERROR: no subcommand provided

See: 'gitdown --help'

On the other hand, I played with a few popular CLI tools that have subcommands - git, docker, and kubectl - and note that all of them show exactly the same behaviour for CMD and CMD --help.

So, I'm a bit torn about whether to change Clamp's default behaviour.

Meanwhile, you could use this trick:

Clamp do

  # ...

  self.default_subcommand = "barf"

  def subcommand_missing(name)
    signal_usage_error "no subcommand specified" if name == "barf"
    super
  end

end

@DannyBen
Copy link
Author

I see your point. I never actually made the distinction between CLI with subcommands, and without.

@mdub
Copy link
Owner

mdub commented Jun 16, 2018

I'm still torn on this one. I'm tempted to change the default behaviour as suggested, ie.

$ ./examples/gitdown 
ERROR: no subcommand provided

See: 'gitdown --help'

@mdub
Copy link
Owner

mdub commented Oct 16, 2018

I'm going to default to the devil we know, i.e. not changing current behaviour.

@mdub mdub closed this as completed Oct 16, 2018
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

2 participants