NewAnalysisCmd returns a new instance of the 'analysis' command.
()
| 36 | |
| 37 | // NewAnalysisCmd returns a new instance of the 'analysis' command. |
| 38 | func NewAnalysisCmd() *cobra.Command { |
| 39 | cmd := &cobra.Command{ |
| 40 | Aliases: []string{"an"}, |
| 41 | Use: "analysis [hash]...", |
| 42 | Short: "Get a file or URL analysis", |
| 43 | Long: analysisCmdHelp, |
| 44 | Example: analysisCmdExample, |
| 45 | Args: cobra.MinimumNArgs(1), |
| 46 | |
| 47 | RunE: func(cmd *cobra.Command, args []string) error { |
| 48 | re, _ := regexp.Compile(`(f|u)-[[:xdigit:]]{64}-\d+|[\d\w=]{20,}`) |
| 49 | p, err := NewPrinter(cmd) |
| 50 | if err != nil { |
| 51 | return err |
| 52 | } |
| 53 | return p.GetAndPrintObjects( |
| 54 | "analyses/%s", |
| 55 | utils.StringReaderFromCmdArgs(args), |
| 56 | re) |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | addThreadsFlag(cmd.Flags()) |
| 61 | addIncludeExcludeFlags(cmd.Flags()) |
| 62 | addIDOnlyFlag(cmd.Flags()) |
| 63 | |
| 64 | return cmd |
| 65 | } |
no test coverage detected