CLI11 icon indicating copy to clipboard operation
CLI11 copied to clipboard

Is it possible to bind multiple envname using one Option * instance?

Open nanoric opened this issue 5 years ago • 4 comments

For compatibility, I set multiple names for a flag/option.

auto option = group->add_flag("--name-a,--name-b", ...).

But for now it seems that binding multiple envname to one Option instance is impossible.

option->envname("NAME_A,NAME_B");
// or
option->envname("NAME_A")->envname("NAME_B")

even though writing two options is possible, but is there a better way to do this?

group->add_flag("--name-a", ...)->envname("NAME_A").
group->add_flag("--name-b", ...)->envname("NAME_B").

Is there any plan for this?

nanoric avatar Nov 29 '20 11:11 nanoric

I don't think there are any plans to change this.

The best option is likely to be separate flags that assign to the same variable like you did.

supporting it like you describe would add a lot of complexity for limited benefit, especially since there is a straightforward alternate path to achieve the same result.

phlptp avatar Dec 01 '20 16:12 phlptp

Maybe using this form is ok:

envname("NAME_A,NAME_B")

Will you merge this change if I create a PR for this?

nanoric avatar Dec 02 '20 08:12 nanoric

would have to leave to @henryiii to decide.

phlptp avatar Dec 04 '20 22:12 phlptp

This is actually rather nicely symmetric with how we currently handle multiple option names. I think I'd be fine with it if it didn't add much complexity.

henryiii avatar Dec 28 '20 16:12 henryiii