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

Ordered options #567

Closed
perrygeo opened this issue Apr 28, 2016 · 3 comments
Closed

Ordered options #567

perrygeo opened this issue Apr 28, 2016 · 3 comments

Comments

@perrygeo
Copy link

I have a situation where I need to know the order of multiple multi-value options. i.e.

--gamma b 0.95 --sigmoidal-contrast r,g,b 5 0.5 --saturation 120

is different from

--saturation 120 --sigmoidal-contrast r,g,b 5 0.5  --gamma b 0.95

Is there any way to retain the order of the supplied options or is this outside of click's scope? Does anyone have any suggestions for different click-based designs that would accomplish the same task (short of writing a DSL)?

@untitaker
Copy link
Contributor

I think your proposal in mapbox/rio-color#23, plus the first solution (using non-space as delimiter) is much better. A "click-based" design also means to me that it wouldn't violate the strong opinions about semantics that come with Click (e.g. unordered options). Unsurprisingly I happen to agree with those opinions.

What about this DSL:

rio color in.tif out.tif gamma r,g 1.05 saturation 125

This is still unambigous assuming all your filters accept a constant amount of args.

With all that said, you can, in theory, preserve the order by subclassing click.Command and overriding parse_args.

@perrygeo
Copy link
Author

@untitaker Thanks for the input - at least I can rest assured that I'm not missing something obvious in the click docs.

Overriding parse_args might be an interesting approach but probably a last resort.

The unquoted DSL approach might work very well, thanks for the suggestion!

@untitaker
Copy link
Contributor

I'll close this then as there's nothing actionable. Good luck.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants