mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: provide usage instruction for CLI argument failures (#12309)
* chore: add usage to # cli arg failures
This commit is contained in:
+12
-2
@@ -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
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user