You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Package cliarg extends cobra.Args to allow for custom error messages.
2
+
//
3
+
// Usage:
4
+
//
5
+
// cliarg.ExactNamedArgs("workspace", "This command requires a workspace name to be passed. Run this command with '--help' to see an example.")
6
+
//
7
+
// Will produce the following error message when calling
8
+
//
9
+
// Error: this command accepts 'workspace' as an argument, received no arguments. Pass in 'workspace' or call command with '--help' to see an example.")
10
+
//
11
+
package cliflag
12
+
13
+
import (
14
+
"fmt"
15
+
16
+
"github.com/spf13/cobra"
17
+
)
18
+
19
+
// Expects 1 arg based on namedArg, otherwise returns customErrorMessage
returnfmt.Errorf("this command accepts <%s> as an argument, received no arguments. Pass in arg or call command with '--help' to see an example.", namedArg)
0 commit comments