NewCmd create the new "status" subcommand
()
| 31 | |
| 32 | // NewCmd create the new "status" subcommand |
| 33 | func NewCmd() *cobra.Command { |
| 34 | statusCmd := &cobra.Command{ |
| 35 | Use: "status CLUSTER", |
| 36 | Short: "Get the status of a PostgreSQL cluster", |
| 37 | Args: plugin.RequiresArguments(1), |
| 38 | GroupID: plugin.GroupIDDatabase, |
| 39 | ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 40 | if strings.HasPrefix(toComplete, "-") { |
| 41 | fmt.Printf("%+v\n", toComplete) |
| 42 | } |
| 43 | return plugin.CompleteClusters(cmd.Context(), args, toComplete), cobra.ShellCompDirectiveNoFileComp |
| 44 | }, |
| 45 | RunE: func(cmd *cobra.Command, args []string) error { |
| 46 | ctx := cmd.Context() |
| 47 | clusterName := args[0] |
| 48 | |
| 49 | verbose, _ := cmd.Flags().GetCount("verbose") |
| 50 | output, _ := cmd.Flags().GetString("output") |
| 51 | timeout, _ := cmd.Flags().GetDuration("timeout") |
| 52 | |
| 53 | return Status(ctx, clusterName, verbose, plugin.OutputFormat(output), timeout) |
| 54 | }, |
| 55 | } |
| 56 | |
| 57 | statusCmd.Flags().CountP( |
| 58 | "verbose", "v", "Increase verbosity to display more information") |
| 59 | statusCmd.Flags().StringP( |
| 60 | "output", "o", "text", "Output format. One of text|json") |
| 61 | statusCmd.Flags().DurationP( |
| 62 | "timeout", "t", 10*time.Second, "Timeout for operations that access pod filesystems (e.g., du, cat)") |
| 63 | |
| 64 | return statusCmd |
| 65 | } |
no test coverage detected