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

Args: false to stop passing unparsed arguments #1797

Closed
3 tasks done
abitrolly opened this issue Jul 19, 2023 · 1 comment
Closed
3 tasks done

Args: false to stop passing unparsed arguments #1797

abitrolly opened this issue Jul 19, 2023 · 1 comment
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this

Comments

@abitrolly
Copy link
Contributor

My urfave/cli version is

2.25.7

Checklist

  • Are you running the latest v2 release? The list of releases is here.
  • Did you check the manual for your release? The v2 manual is here
  • Did you perform a search about this problem? Here's the GitHub guide about searching.

Dependency Management

  • My project is using go modules.

Describe the bug

#1069 requests an option to avoid printing args help when args are not used. ArgsUsage allows to customize args message, but when it is empty, the default is being printed.

Even with such option, args will still be passed to function when user specifies them by mistake.

The proposal is to add boolean Args option that will both turn off the args help message, and will make it an error to pass arguments.

@@ -22,9 +22,11 @@ type statsFlags struct {
 func statsCommand() cli.Command {
        var statsFlags statsFlags
        stats := cli.Command{
                Name:      "stats",
                Usage:     "Output useful statistics about a SCIP index",
+               Args:      false,
+               ArgsUsage: " ",
                Flags:     []cli.Flag{fromFlag(&statsFlags.from)},
                Action: func(c *cli.Context) error {
                        return statsMain(statsFlags)
                },

To reproduce

https://cli.urfave.org/v2/getting-started/ should error out if Args: false and user supplied undefined argument.

Observed behavior

Specifying undefined arguments do not make any errors.

Expected behavior

Error out.

Additional context

Want to fix this yourself?

Maybe.

Run go version and paste its output here

# paste `go version` output in here

Run go env and paste its output here

# paste `go env` output in here
@abitrolly abitrolly added kind/bug describes or fixes a bug area/v2 relates to / is being considered for v2 status/triage maintainers still need to look into this labels Jul 19, 2023
@dolmen
Copy link
Contributor

dolmen commented Dec 21, 2023

What do you want?

  • undocumented flags (flags that work, but are not exposed in usage)?
  • declare flags that must not work: so why are you even declaring that flag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this
Projects
None yet
Development

No branches or pull requests

3 participants