Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cmds.Command{ Subcommands: map[string]*cmds.Command{ "add": &cmds.Command{ Arguments: []cmdkit.Argument{ cmdkit.StringArg("summands", true, true, "values that are supposed to be summed"), }, Run: func(req cmds.Request, re cmds.ResponseEmitter) { sum := 0 for i, str := range req.Arguments() { num, err := strconv.Atoi(str) if err != nil { re.SetError(err, cmdkit.ErrNormal) return } sum += num re.Emit(fmt.Sprintf("intermediate result: %d; %d left", sum, len(req.Arguments())-i-1)) } re.Emit(fmt.Sprintf("total: %d", sum)) }, }, }, }
Define the root of the commands
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.