chore: provide usage instruction for CLI argument failures (#12309)

* chore: add usage to # cli arg failures
This commit is contained in:
Steven Masley
2024-02-28 12:10:17 -06:00
committed by GitHub
parent 30d9d84758
commit 97f083810f
2 changed files with 25 additions and 4 deletions
+12 -2
View File
@@ -45,7 +45,8 @@ func (RootCmd) errorExample() *clibase.Cmd {
apiError.(*codersdk.Error).Helper = "Have you tried turning it off and on again?"
//nolint:errorlint,forcetypeassert
apiErrorNoHelper := apiError.(*codersdk.Error)
cpy := *apiError.(*codersdk.Error)
apiErrorNoHelper := &cpy
apiErrorNoHelper.Helper = ""
// Some flags
@@ -94,7 +95,6 @@ func (RootCmd) errorExample() *clibase.Cmd {
)
},
},
{
Use: "validation",
Options: clibase.OptionSet{
@@ -114,6 +114,16 @@ func (RootCmd) errorExample() *clibase.Cmd {
return nil
},
},
{
Use: "arg-required <required>",
Middleware: clibase.Chain(
clibase.RequireNArgs(1),
),
Handler: func(i *clibase.Invocation) error {
_, _ = fmt.Fprint(i.Stdout, "Try running this without an argument\n")
return nil
},
},
},
}