MCPcopy Create free account
hub / github.com/VirusTotal/vt-cli / NewFileCmd

Function NewFileCmd

cmd/file.go:40–76  ·  view source on GitHub ↗

NewFileCmd returns a new instance of the 'file' command.

()

Source from the content-addressed store, hash-verified

38
39// NewFileCmd returns a new instance of the 'file' command.
40func NewFileCmd() *cobra.Command {
41 cmd := &cobra.Command{
42 Use: "file [hash]...",
43 Short: "Get information about files",
44 Long: fileCmdHelp,
45 Example: fileCmdExample,
46 Args: cobra.MinimumNArgs(1),
47
48 RunE: func(cmd *cobra.Command, args []string) error {
49 re, _ := regexp.Compile("[[:xdigit:]]{64}|[[:xdigit:]]{40}|[[:xdigit:]]{32}")
50 p, err := NewPrinter(cmd)
51 if err != nil {
52 return err
53 }
54 if viper.GetBool("private") {
55 return p.GetAndPrintObjectsWithFallback(
56 []string{"files/%s", "private/files/%s"},
57 utils.StringReaderFromCmdArgs(args),
58 re)
59 } else {
60 return p.GetAndPrintObjects(
61 "files/%s",
62 utils.StringReaderFromCmdArgs(args),
63 re)
64 }
65 },
66 }
67
68 addRelationshipCmds(cmd, "files", "file", "[hash]", true)
69
70 addThreadsFlag(cmd.Flags())
71 addIncludeExcludeFlags(cmd.Flags())
72 addIDOnlyFlag(cmd.Flags())
73 addPrivateFlag(cmd.Flags())
74
75 return cmd
76}

Callers 1

NewVTCommandFunction · 0.85

Calls 9

GetAndPrintObjectsMethod · 0.95
StringReaderFromCmdArgsFunction · 0.92
addRelationshipCmdsFunction · 0.85
addThreadsFlagFunction · 0.85
addIncludeExcludeFlagsFunction · 0.85
addIDOnlyFlagFunction · 0.85
addPrivateFlagFunction · 0.85
NewPrinterFunction · 0.70

Tested by

no test coverage detected