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

Improve documentation for clap::Args::augment_args and clap::Args::augment_args_for_update #5682

Open
2 tasks done
nwalfield opened this issue Aug 16, 2024 · 1 comment
Open
2 tasks done
Labels
C-bug Category: Updating dependencies

Comments

@nwalfield
Copy link

Please complete the following tasks

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21)

Clap Version

4.4.18

Minimal reproducible code

Read the documentation for clap::Args:

fn augment_args(cmd: Command) -> Command`

Append to Command so it can instantiate Self.

See also CommandFactory.
source

fn augment_args_for_update(cmd: Command) -> Command`

Append to Command so it can update self.

This is used to implement #[command(flatten)]

See also CommandFactory.

The documentation does not describe how to implement Args::augment_args or Args::augment_args_for_update, and it only hints at the difference between them. The documentation links to CommandFactory, but that doesn't really help either. The flatten_hand_args.rs example provides a basic idea, but I still have to guess at the semantics. Further, the example's implementation of augment_args and augment_args_for_update are identical, which is baffling. I tried reading the source code, but still couldn't figure out the difference between the two.

Steps to reproduce the bug with the above code

Read the above documentation.

Actual Behaviour

The current documentation is missing details. The example is good, but incomplete.

Expected Behaviour

The documentation should describe the semantics of the two methods. It should also make clearer what the difference between the two is (what does so it can instantiate Self vs so it can update Self mean).

Additional Context

This seemed like the most appropriate template for this documentation issue. I apologize if I should have chosen a different template.

Debug Output

No response

@nwalfield nwalfield added the C-bug Category: Updating dependencies label Aug 16, 2024
@epage
Copy link
Member

epage commented Aug 16, 2024

5488bcf, df165a2, a3a4764 tweaked the wording.

Whether the update calls need any different logic is dependent on the situation. The main situation I can remember when polishing it up for release was that there are no required arguments.

Overall, update adds a lot of complexity for a very small number of users that I am tempted to just remove it (#4974).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants