Skip to content

Commit

Permalink
fix: Clean up command error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Toh <tohjustin@hotmail.com>
  • Loading branch information
tohjustin committed Oct 3, 2021
1 parent 2848c8e commit 835a004
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/cmd/lineage/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var (

//nolint:gochecknoinits
func init() {
// If executed as a kubectl plugin
if strings.HasPrefix(filepath.Base(os.Args[0]), "kubectl-") {
cmdName = "kubectl lineage"
}
Expand Down Expand Up @@ -137,6 +138,7 @@ func New(streams genericclioptions.IOStreams) *cobra.Command {
Example: strings.ReplaceAll(cmdExample, "COMMAND", cmdName),
Short: cmdShort,
Long: cmdLong,
Args: cobra.MaximumNArgs(2),
DisableFlagsInUseLine: true,
DisableSuggestions: true,
SilenceUsage: true,
Expand All @@ -162,15 +164,15 @@ func (o *CmdOptions) Complete(cmd *cobra.Command, args []string) error {
case 1:
resourceTokens := strings.SplitN(args[0], "/", 2)
if len(resourceTokens) != 2 {
return fmt.Errorf("you must specify one or two arguments: resource or resource & resourceName")
return fmt.Errorf("arguments in <resource>/<name> form must have a single resource and name\nSee '%s -h' for help and examples", cmdName)
}
resourceType = resourceTokens[0]
resourceName = resourceTokens[1]
case 2:
resourceType = args[0]
resourceName = args[1]
default:
return fmt.Errorf("you must specify one or two arguments: resource or resource & resourceName")
return fmt.Errorf("resource must be specified as <resource> <name> or <resource>/<name>\nSee '%s -h' for help and examples", cmdName)
}
restMapper, err := o.ConfigFlags.ToRESTMapper()
if err != nil {
Expand Down

0 comments on commit 835a004

Please sign in to comment.