// interactive displays a prompt and reads commands for profile // manipulation/visualization. func interactive(p *profile.Profile, obj plugin.ObjTool, ui plugin.UI, f *flags) error { updateAutoComplete(p) // Enter command processing loop. ui.Print("Entering interactive mode (type \"help\" for commands)") ui.SetAutoComplete(commands.NewCompleter(f.commands)) for { input, err := readCommand(p, ui, f) if err != nil { if err != io.EOF { return err } if input == "" { return nil } } // Process simple commands. switch input { case "": continue case ":": f.flagFocus = newString("") f.flagIgnore = newString("") f.flagTagFocus = newString("") f.flagTagIgnore = newString("") f.flagHide = newString("") continue } fields := splitCommand(input) // Process report generation commands. if _, ok := f.commands[fields[0]]; ok { if err := generateReport(p, fields, obj, ui, f); err != nil { if err == io.EOF { return nil } ui.PrintErr(err) } continue } switch cmd := fields[0]; cmd { case "help": commandHelp(fields, ui, f) continue case "exit", "quit": return nil } // Process option settings. if of, err := optFlags(p, input, f); err == nil { f = of } else { ui.PrintErr("Error: ", err.Error()) } } }