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

Allow to mark arguments as to be ignored by suggestions. #5097

Closed
wants to merge 1 commit into from

Conversation

Carreau
Copy link

@Carreau Carreau commented Aug 28, 2023

As pointed out in #4853, it might be useful to mark arguments to not be considered by the suggestions feature.

In particular with the introduction of UnknownArgumentValueParser in #5075, one might want explicitly handle some common confusion (say handle --silent and print tip: did you mean --quiet), but not have those in the suggestion engine. I'm guessing one might want to have an arg be visible but not in suggestion for deprecated flags as well.

I'm trying to do so by adding a .didyoumena(false), that will mark the argument as to not be considered by suggestion.

There is also some mention of completion of hidden command in #4853, that might be relevant as well.

--

I'm not too familiar with clap internals, and fairly new to rust, but in particular :

  • I've tried to implement that only for args - I guess we will need to extend to subcommands if this goes further
  • I'm not happy with the setting negations nor the naming didyoumean/ExcludeDidYouMean
  • I'm not super happy about the iteration over MKeyMap keys and items.

As pointed out in clap-rs#4853, it might be useful to mark arguments to not be
considered by the suggestions feature.

In particular with the introduction of UnknownArgumentValueParser in clap-rs#5075,
one might want explicitly handle some common confusion (say handle
`--silent` and print `tip: did you mean --quiet`), but not have those in
the suggestion engine. I'm guessing one might want to have an `arg` be visible
but not in suggestion for deprecated flags as well.

I'm trying to do so by adding a `.didyoumena(false)`, that will mark the
argument as to not be considered by suggestion.

There is also some mention of completion of hidden command in clap-rs#4853,
that might be relevant as well.

--

I'm not too familiar with clap internals, and fairly new to rust,
but in particular :

 - I've tried to implement that only for args - I guess we will need to
   extend to subcommands if this goes further
 - I'm not happy with the setting negations nor the naming
   `didyoumean`/`ExcludeDidYouMean`
 - I'm not super happy about the iteration over MKeyMap keys and items.
@@ -4153,6 +4193,11 @@ impl Arg {
self.is_set(ArgSettings::HideEnv)
}

/// dont did you mean
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self, needs docs.

@epage
Copy link
Member

epage commented Aug 28, 2023

FYI discussions around new features should happen in issues before moving to PRs. As this is a draft, I'm leaving it open in case you had some intent to show something by this but I don't see much to gained from it at this point in discussions.

@Carreau
Copy link
Author

Carreau commented Aug 28, 2023

FYI discussions around new features should happen in issues before moving to PRs. As this is a draft, I'm leaving it open in case you had some intent to show something by this but I don't see much to gained from it at this point in discussions.

No worries, I was mostly curious of how it was possible, and as the code was written and works for args, I though it was a better way to show how it could look like. I was going to comment on #4853 (which I am going to do now), but took a break and you replied quasi immediately :-)

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

Successfully merging this pull request may close these issues.

None yet

2 participants