Cli: Slice Flags help output is unexpected/confusing

Created on 13 Jan 2014  路  18Comments  路  Source: urfave/cli

Using a flag such as

cli.StringSliceFlag{"lang", &cli.StringSlice{"english", "spanish"}, "language for the greeting"},

results in help output like this:

OPTIONS:
   --lang [english spanish] `-lang option -lang option` language for the greeting

What exactly is the intended meaning of "-lang option -lang option"? Am I just uninformed or is this a WIP? I'd be happy to work on it if I know what it's supposed to do! :)

arev2 help wanted kindocumentation kinfeature statuconfirmed statustale

Most helpful comment

I also ran into this using etcdctl. Check this out:

--peers, C [] -peers, C option -peers, C option a comma-delimited list of machine addresses in the cluster (default: {"127.0.0.1:4001"})

But actually doing something like -peers 127.0.0.1,127.0.0.2 doesn't work. What does work is specifying it multiple times like peers 127.0.0.1 -peers 127.0.0.2.

All 18 comments

If you use an example like this one

cli.StringSliceFlag{
    "dns", 
    &cli.StringSlice{"8.8.8.8", "8.8.4.4"}, //here we are setting some predefined  values
    "set one or more dns Servers"
},

help output

OPTIONS:
   --dns [8.8.8.8  4.4.4.4] `-dns option -dns option` set one or more dns Servers

does it make sense now?

It seems like the confusing part of the help output is the word "option" in -lang option -lang option

@thesyncim I appreciate the explanation! However, I'm more confused by what @tjarratt is referring to.

@cab sorry, I was trying to explain which part of the help message I found confusing. The part that I find most confusing is the word "option". It would be easier to understand if there was some indication that option is really just a placeholder for user input.

@tjarratt I worded my last response poorly, I meant to say that I'm confused by the same thing :).

I also ran into this using etcdctl. Check this out:

--peers, C [] -peers, C option -peers, C option a comma-delimited list of machine addresses in the cluster (default: {"127.0.0.1:4001"})

But actually doing something like -peers 127.0.0.1,127.0.0.2 doesn't work. What does work is specifying it multiple times like peers 127.0.0.1 -peers 127.0.0.2.

I agree that it is a little confusing. Would something like -lang <option> -lang <option> be more clear?

I would expect the output to show cleanly the default values, like any other flag:

OPTIONS:
   --lang english, --lang spanish    language for the greeting

@vieux agreed, but how would you also display the short name there (in non-slice types it has --lang, l 'english', but something like --lang, -l english, --lang, -l spanish language for the greeting looks weird). I guess this would be solved by specifying the defaults after the usage (or allowing the user to template in the defaults like in Python's optparse), but I'm not sure if that would be breaking the API of this library.

The help output for slice types has been changed (significantly?) since this issue was last updated, and I don't think it's relevant anymore. Please yell if you disagree!

Current help output for slice flags is not intuitive. It does not provide any hint that the flag should be specified multiple times. For example, the following is a slice flag

   --domains value, -d value   Add domains to the process

...how will the user know that they should include this multiple times if they want to pass in multiple domains!? A naive user might attempt to put all the domains together e.g. --domains example1.com example2.com

This form makes more sense to me:

  --domains, -d [--domains option --domains option]            Add domains to the process

Agreed, reopening

I will jump to the discussion and say that I would agree with @jefferai something like

--items=1.2.3.4/32,2.3.4.5/32

or ...

--items="1.2.3.4/32 2.3.4.5/32"

Would make more sense in my use case scenarios.

This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

\\ bump ^^ I think there's definitely something we could do here

This issue or PR has been bumped and is no longer marked as stale! Feel free to bump it again in the future, if it's still relevant.

This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else.

Closing this as it has become stale.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

l0k18 picture l0k18  路  3Comments

krostar picture krostar  路  5Comments

renzhengeek picture renzhengeek  路  5Comments

lynncyrin picture lynncyrin  路  3Comments

nkprince007 picture nkprince007  路  5Comments