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

feature: introduce concept of named parameters instead of optional parameters #61

Closed
cherusk opened this issue May 31, 2020 · 6 comments
Labels
docs Improvements or additions to documentation enhancement New feature or request

Comments

@cherusk
Copy link
Contributor

cherusk commented May 31, 2020

I don't like the delineation of optional/positional. Optionality should be a trait of the parameter, indifferent of how it is passed.

Hence, new delineation would be positional or named, the current "optional".

That's how argparse[1] does it essentially.

[1] https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument

@cherusk cherusk changed the title feature: introduce concept of named parameters feature: introduce concept of named parameters instead of optional parameters May 31, 2020
@jacobdeichert
Copy link
Owner

Hmmm not quite sure if I'm missing something here... but I think "named parameters" is the same thing as optional flags.

The idea with positional required/optional args is that they are for really simple cases. If you need more complex parameters, then optional flags might be better.

Do you maybe want the ability to mark certain flags as required?

@cherusk
Copy link
Contributor Author

cherusk commented Jun 1, 2020 via email

@jacobdeichert
Copy link
Owner

Exactly, but that goes not only for "named", but also for positional
params.

So positional args are already always required.

For optional flags, apparently clap does support making flags required.

I think we can support this by adding a new field to our optional flag definition:

## cmd

**OPTIONS**
* check
    * flags: -c --check
    * desc: Show which files are not formatted correctly
    * required

If our parser finds * required, then the flag is marked as required.

Pretty easy to support if anyone wants to make a PR 👍

@jacobdeichert jacobdeichert added docs Improvements or additions to documentation enhancement New feature or request labels Aug 10, 2020
@cherusk
Copy link
Contributor Author

cherusk commented Oct 11, 2020

So positional args are already always required.

Find that wrong though as said.

Pretty easy to support if anyone wants to make a PR +1

Will implement it.

@cherusk
Copy link
Contributor Author

cherusk commented Oct 11, 2020

Clap is amazing. :)

@jacobdeichert
Copy link
Owner

Marking as closed due to #74

Aiming for a release this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants