metropolis/cli/metroctl: don't print usage for runtime errors
Change-Id: I91fdca45e874ea1ec9112df556a9a7392fd45bfd
Fixes: https://github.com/monogon-dev/monogon/issues/352
Reviewed-on: https://review.monogon.dev/c/monogon/+/3440
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/cmd_node.go b/metropolis/cli/metroctl/cmd_node.go
index 59b4d9b..d7a23ee 100644
--- a/metropolis/cli/metroctl/cmd_node.go
+++ b/metropolis/cli/metroctl/cmd_node.go
@@ -53,7 +53,7 @@
}
printNodes(nodes, args, columns)
},
- Args: cobra.ArbitraryArgs,
+ Args: PrintUsageOnWrongArgs(cobra.ArbitraryArgs),
}
var nodeListCmd = &cobra.Command{
@@ -72,7 +72,7 @@
printNodes(nodes, args, map[string]bool{"node id": true})
},
- Args: cobra.ArbitraryArgs,
+ Args: PrintUsageOnWrongArgs(cobra.ArbitraryArgs),
}
var nodeUpdateCmd = &cobra.Command{
@@ -225,7 +225,7 @@
return nil
},
- Args: cobra.MinimumNArgs(1),
+ Args: PrintUsageOnWrongArgs(cobra.MinimumNArgs(1)),
}
var nodeDeleteCmd = &cobra.Command{
@@ -283,7 +283,7 @@
_, err = mgmt.DeleteNode(ctx, req)
return err
},
- Args: cobra.ExactArgs(1),
+ Args: PrintUsageOnWrongArgs(cobra.ExactArgs(1)),
}
func dialNode(ctx context.Context, node string) (apb.NodeManagementClient, error) {
@@ -331,7 +331,7 @@
--firmware flag. This flag cannot be combined with any others.
`,
Use: "reboot [node-id]",
- Args: cobra.ExactArgs(1),
+ Args: PrintUsageOnWrongArgs(cobra.ExactArgs(1)),
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
@@ -385,7 +385,7 @@
var nodePoweroffCmd = &cobra.Command{
Short: "Power off a node",
Use: "poweroff [node-id]",
- Args: cobra.ExactArgs(1),
+ Args: PrintUsageOnWrongArgs(cobra.ExactArgs(1)),
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()