fix(cmd/ry): silence cobra error dup + fix bucket/dns Use&Args warts

This commit is contained in:
2026-08-13 12:21:36 +08:00
parent 66a7bdcbd5
commit 706fe752a0
3 changed files with 7 additions and 7 deletions
+2 -3
View File
@@ -41,13 +41,12 @@ func Cmd(rySDK **sdk.RainyunSDK, out **output.Printer) *cobra.Command {
} }
dnsCmd := &cobra.Command{ dnsCmd := &cobra.Command{
Use: "dns <domain-id>", Use: "dns",
Short: "Manage DNS records", Short: "Manage DNS records",
Args: cobra.ExactArgs(1),
} }
dnsListCmd := &cobra.Command{ dnsListCmd := &cobra.Command{
Use: "list", Use: "list <domain-id>",
Short: "List DNS records", Short: "List DNS records",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0]) id, err := strconv.Atoi(args[0])
+3 -4
View File
@@ -42,13 +42,12 @@ func Cmd(rySDK **sdk.RainyunSDK, out **output.Printer) *cobra.Command {
} }
bucketCmd := &cobra.Command{ bucketCmd := &cobra.Command{
Use: "bucket <instance-id>", Use: "bucket",
Short: "Manage buckets", Short: "Manage buckets",
Args: cobra.ExactArgs(1),
} }
bucketListCmd := &cobra.Command{ bucketListCmd := &cobra.Command{
Use: "list", Use: "list <instance-id>",
Short: "List buckets", Short: "List buckets",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
instanceID, err := strconv.Atoi(args[0]) instanceID, err := strconv.Atoi(args[0])
@@ -71,7 +70,7 @@ func Cmd(rySDK **sdk.RainyunSDK, out **output.Printer) *cobra.Command {
} }
bucketCreateCmd := &cobra.Command{ bucketCreateCmd := &cobra.Command{
Use: "create <name>", Use: "create <instance-id> <name>",
Short: "Create a bucket", Short: "Create a bucket",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
+2
View File
@@ -76,6 +76,8 @@ Use "ry [command] --help" for more information about a command.`,
} }
func init() { func init() {
rootCmd.SilenceErrors = true
rootCmd.SilenceUsage = true
cfgPath = config.DefaultPath() cfgPath = config.DefaultPath()
rootCmd.PersistentFlags().StringVar(&flagAPIKey, "apikey", "", "Rainyun API key") rootCmd.PersistentFlags().StringVar(&flagAPIKey, "apikey", "", "Rainyun API key")
rootCmd.PersistentFlags().StringVarP(&flagOutput, "output", "o", "", "Output format: table, json, yaml, raw") rootCmd.PersistentFlags().StringVarP(&flagOutput, "output", "o", "", "Output format: table, json, yaml, raw")