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

Method PrintCommandLineWithCursor

utils/printer.go:256–281  ·  view source on GitHub ↗

PrintCommandLineWithCursor prints the same command-line that was used for executing the program but adding or replacing the --cursor flag with the current cursor for the given iterator.

(it *vt.Iterator)

Source from the content-addressed store, hash-verified

254// executing the program but adding or replacing the --cursor flag with
255// the current cursor for the given iterator.
256func (p *Printer) PrintCommandLineWithCursor(it *vt.Iterator) {
257 if cursor := it.Cursor(); cursor != "" {
258 args := p.cmd.Flags().Args()
259 for i, arg := range args {
260 args[i] = fmt.Sprintf("'%s'", arg)
261 }
262 flags := make([]string, 0)
263 p.cmd.Flags().Visit(func(flag *pflag.Flag) {
264 if flag.Name != "cursor" {
265 var f string
266 switch flag.Value.Type() {
267 case "stringSlice":
268 ss, _ := p.cmd.Flags().GetStringSlice(flag.Name)
269 f = fmt.Sprintf("--%s='%s'", flag.Name, strings.Join(ss, ","))
270 default:
271 f = fmt.Sprintf("--%s=%v", flag.Name, flag.Value.String())
272 }
273 flags = append(flags, f)
274 }
275 })
276 flags = append(flags, fmt.Sprintf("--cursor=%s", cursor))
277 color.New(color.Faint).Fprintf(
278 ansi.NewAnsiStderr(), "\nMORE WITH:\n%s %s %s\n",
279 p.cmd.CommandPath(), strings.Join(args, " "), strings.Join(flags, " "))
280 }
281}

Callers 2

PrintIteratorMethod · 0.95
runContentSearchCmdFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected