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

requiring a value be supplied for an option #52

Closed
flyingmachine opened this issue Dec 6, 2022 · 4 comments
Closed

requiring a value be supplied for an option #52

flyingmachine opened this issue Dec 6, 2022 · 4 comments

Comments

@flyingmachine
Copy link

clojure.tools.cli gives you a way to specify that a value must be supplied for an option by specifying the option with something like

["-e" "--entry ENTRY" "Text of your entry"]

If your args include --entry but nothing after, it's treated as an error. Would it be possible to do something similar with this library? :require mandates the presence of an option, but doesn't handle the case where no value is supplied.

@borkdude
Copy link
Contributor

borkdude commented Dec 6, 2022

Yes, but we should only require something after --entry if: the expected type of entry is available and: it's not a boolean, I think?

@borkdude
Copy link
Contributor

I'd say this should fail with a required error:

user=> (cli/parse-opts ["--foo"] {:coerce {:foo :number}})
{:foo true}

and this should not, as booleans may just be the flag:

user=> (cli/parse-opts ["--foo"] {:coerce {:foo :boolean}})
{:foo true}

@flyingmachine
Copy link
Author

Yeah, this looks right to me

@borkdude
Copy link
Contributor

OK, I'm working on it

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