The source code for irisctl
follows specific conventions.
If you'd like to contribute, please adhere to these guidelines.
Functions specified in the Run field of cobra.Command:
command: <cmdName>
subcommand: <cmdName><subcmdName>
f<subcmd><flag> // irisctl monitor agents --status => fAgentStatus
agentsCmd := &cobra.Command{
...
}
agentsCmd.SetUsageFunc(common.Usage)
agentsCmd.SetHelpFunc(common.Help)
Args: cmdNameSubcmdNameArgs,
For example:
func usersDeleteArgs(cmd *cobra.Command, args []string) error {
if len(args) == 2 && args[0] == "usage" {
fmt.Printf(args[1], "<user-id>...", "one or more user IDs")
return nil
}
if len(args) < 1 {
cliFatal("users delete requires at least one argument: <user-id>")
}
common.ValidateFormat(args, common.UserID)
return nil
}
cliFatal() // invalid command line
fatal() // errors that should terminate execution
// TODO: mark incomplete work or improvements to be made
// XXX: mark hacky code that needs a better solution but is left as-is for now