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

Ability to require_equals with optional value for long option, but require value for short option. #4702

Open
2 tasks done
tmccombs opened this issue Feb 11, 2023 · 2 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@tmccombs
Copy link
Contributor

Please complete the following tasks

Clap Version

4.0

Describe your use case

mktemp has the following option:

-p DIR, --tmpdir[=DIR]

If using the short option, DIR is required. But if using the long option, DIR is optional, and requires the "=".

Describe the solution you'd like

I'm not really sure. Perhaps the cleanest solution would be to be either some way to use the same id, and help text for multiple Args, or to have some way to provide separate options for the short and long variants.

Alternatives, if applicable

It's possible to work around this by having separate Args for the short and long options. But this can be a little awkward to work with when consuming the arguments, and there isn't a way to combine the help text for the two options.

Additional Context

See uutils/coreutils#3454

@tmccombs tmccombs added the C-enhancement Category: Raise on the bar on expectations label Feb 11, 2023
tmccombs added a commit to tmccombs/coreutils that referenced this issue Feb 11, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tmccombs added a commit to tmccombs/coreutils that referenced this issue Feb 13, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tmccombs added a commit to tmccombs/coreutils that referenced this issue Feb 13, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
@epage
Copy link
Member

epage commented Feb 13, 2023

I feel like this came up elsewhere but I'm not finding it. Maybe its buried in #3030.

There is a sibling request of #4499.

@epage epage added A-parsing Area: Parser's logic and needs it changed somehow. S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing labels Feb 13, 2023
@epage
Copy link
Member

epage commented Feb 13, 2023

My main concern is ensuring we give the user the ability to create the policy they need without bloating compile times, binary size, or the API.

Probably the first step in this is designing out the API.

tmccombs added a commit to tmccombs/coreutils that referenced this issue Mar 30, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tmccombs added a commit to tmccombs/coreutils that referenced this issue Apr 3, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tmccombs added a commit to tmccombs/coreutils that referenced this issue Jun 21, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tmccombs added a commit to tmccombs/coreutils that referenced this issue Jun 22, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
tertsdiepraam pushed a commit to tmccombs/coreutils that referenced this issue Jul 5, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
sylvestre pushed a commit to tmccombs/coreutils that referenced this issue Jul 18, 2023
Fixes uutils#3454

This implementation more closely matches the behavior of GNU mktemp. Specifically,
if using the short-form `-p`, then DIR is required, and if using the long form `--tmpdir`
then DIR is optional, but if provided, must use the `--tmpdir=DIR` form (not `--tempdir DIR`),
so that there is no ambiguity with also passing a TEMPLATE.

The downside to this implementation is we are now introducing a new workaround for
clap-rs/clap#4702 where we use separate calls to `.arg()` for
the short `-p` and the long `--tmpdir`, which results in a less than ideal output for `--help`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

No branches or pull requests

2 participants