()
| 169 | } |
| 170 | |
| 171 | func (cli *cliItem) newInspectCmd() *cobra.Command { |
| 172 | var ( |
| 173 | url string |
| 174 | diff bool |
| 175 | rev bool |
| 176 | noMetrics bool |
| 177 | ) |
| 178 | |
| 179 | cmd := &cobra.Command{ |
| 180 | Use: cmp.Or(cli.inspectHelp.use, "inspect [item]..."), |
| 181 | Short: cmp.Or(cli.inspectHelp.short, "Inspect given "+cli.oneOrMore), |
| 182 | Long: cmp.Or(cli.inspectHelp.long, "Inspect the state of one or more "+cli.name), |
| 183 | Example: cli.inspectHelp.example, |
| 184 | Args: args.MinimumNArgs(1), |
| 185 | DisableAutoGenTag: true, |
| 186 | ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 187 | return compInstalledItems(cli.name, args, toComplete, cli.cfg) |
| 188 | }, |
| 189 | RunE: func(cmd *cobra.Command, args []string) error { |
| 190 | return cli.inspect(cmd.Context(), args, url, diff, rev, noMetrics) |
| 191 | }, |
| 192 | } |
| 193 | |
| 194 | flags := cmd.Flags() |
| 195 | flags.StringVarP(&url, "url", "u", "", "Prometheus url") |
| 196 | flags.BoolVar(&diff, "diff", false, "Show diff with latest version (for tainted items)") |
| 197 | flags.BoolVar(&rev, "rev", false, "Reverse diff output") |
| 198 | flags.BoolVar(&noMetrics, "no-metrics", false, "Don't show metrics (when cscli.output=human)") |
| 199 | |
| 200 | return cmd |
| 201 | } |
| 202 | |
| 203 | func inspectItem(ctx context.Context, hub *cwhub.Hub, item *cwhub.Item, wantMetrics bool, output string, prometheusURL string, wantColor string) error { |
| 204 | // This is dirty... |
no test coverage detected