Commit 06e96b9a authored by Umberto Baldi's avatar Umberto Baldi

refactor debug command and use code from arguments, remove useless vars

parent 83942801
......@@ -35,14 +35,12 @@ import (
)
var (
fqbn string
fqbn arguments.Fqbn
port arguments.Port
verbose bool
verify bool
interpreter string
importDir string
printInfo bool
programmer string
programmer arguments.Programmer
tr = i18n.Tr
)
......@@ -54,18 +52,12 @@ func NewCommand() *cobra.Command {
Long: tr("Debug Arduino sketches. (this command opens an interactive gdb session)"),
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch",
Args: cobra.MaximumNArgs(1),
Run: run,
Run: runDebugCommand,
}
debugCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
debugCommand.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return arguments.GetInstalledBoards(), cobra.ShellCompDirectiveDefault
})
fqbn.AddToCommand(debugCommand)
port.AddToCommand(debugCommand)
debugCommand.Flags().StringVarP(&programmer, "programmer", "P", "", tr("Programmer to use for debugging"))
debugCommand.RegisterFlagCompletionFunc("programmer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return arguments.GetInstalledProgrammers(), cobra.ShellCompDirectiveDefault
})
programmer.AddToCommand(debugCommand)
debugCommand.Flags().StringVar(&interpreter, "interpreter", "console", tr("Debug interpreter e.g.: %s", "console, mi, mi1, mi2, mi3"))
debugCommand.Flags().StringVarP(&importDir, "input-dir", "", "", tr("Directory containing binaries for debug."))
debugCommand.Flags().BoolVarP(&printInfo, "info", "I", false, tr("Show metadata about the debug session instead of starting the debugger."))
......@@ -73,7 +65,7 @@ func NewCommand() *cobra.Command {
return debugCommand
}
func run(command *cobra.Command, args []string) {
func runDebugCommand(command *cobra.Command, args []string) {
instance := instance.CreateAndInit()
path := ""
......@@ -87,12 +79,12 @@ func run(command *cobra.Command, args []string) {
debugConfigRequested := &dbg.DebugConfigRequest{
Instance: instance,
Fqbn: fqbn,
Fqbn: fqbn.String(),
SketchPath: sketchPath.String(),
Port: discoveryPort.ToRPC(),
Interpreter: interpreter,
ImportDir: importDir,
Programmer: programmer,
Programmer: programmer.String(),
}
if printInfo {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment