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

default_value output is incorrect when type is supplied #285

Open
logicminds opened this issue Dec 18, 2018 · 2 comments
Open

default_value output is incorrect when type is supplied #285

logicminds opened this issue Dec 18, 2018 · 2 comments
Labels

Comments

@logicminds
Copy link

Example:

$ cb help
GLOBAL OPTIONS
    --exporters=arg - List of exporters to transform the data (default: ["table", "stdout"])
    --help          - Show this message
    --version       - Display the program version

The default in the flag help output contains an array:
default: ["table", "stdout"]

However, when a user supplies this value they might think they need to supply ["table", "stdout"]

Flag attribute is configured like so:
flag [:exporters], desc: "List of exporters to transform the data", default_value: ['table','stdout'], type: Array

However, when a user is supplying the flag they would use --exporters=table,stdout and not --exporters=['table','stdout']

This is confusing for the user. The default_value value should be a real world value that will be processed by the type conversion system of GLI.

default_value: "table,stdout"

@davetron5000
Copy link
Owner

I see, yeah, agreed this should be better.

@logicminds
Copy link
Author

As a workaround I just changed the type to String and processed the incoming value.

flag [:exporters], desc: "List of exporters to transform the data", default_value: 'table,stdout', type: String

I don't know if transforming the data in the pre is abusing this pre block, but I didn't see another way. A transform block on the flag would have been nice to pass in.

pre do |_global, command, options, _args|
  options[:exporters] = options[:exporters].split(',')
end

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

No branches or pull requests

2 participants