Skip to content

Commit

Permalink
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
@@ -97,7 +97,9 @@ func (cmd *Command) SetAction(action func() error) *Command {

// NewCommand returns a new sub-command named name with the description.
//
// Notice: if the command has existed, it will return the old.
// Notice:
// 1. If the command has existed, it will return the old.
// 2. The command name should only contain the characters, [-_a-zA-Z0-9].
func (cmd *Command) NewCommand(name, description string) (c *Command) {
if c = cmd.commands[name]; c == nil {
c = newCommand(cmd.conf, cmd, name, description, cmd.OptGroup.paths...)
4 changes: 3 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
@@ -569,7 +569,9 @@ func (c *Config) GetAction(name string) func() error {

// NewCommand news a Command to register the CLI sub-command.
//
// Notice: if the command exists, it returns the old, not a new one.
// Notice:
// 1. If the command exists, it returns the old, not a new one.
// 2. The command name should only contain the characters, [-_a-zA-Z0-9].
func (c *Config) NewCommand(name, help string) (cmd *Command) {
c.panicIsParsed(true)
if cmd = c.commands[name]; cmd == nil {
4 changes: 3 additions & 1 deletion group.go
Original file line number Diff line number Diff line change
@@ -150,7 +150,9 @@ func (g *OptGroup) newGroup(name string, paths []string) (group *OptGroup) {

// NewGroup returns a sub-group named name.
//
// Notice: if the sub-group has existed, it will the old.
// Notice:
// 1. If the sub-group has existed, it will the old.
// 2. The command name should only contain the characters, [-_a-zA-Z0-9].
func (g *OptGroup) NewGroup(name string) *OptGroup {
return g.newGroup(name, g.paths)
}

0 comments on commit 1272ff2

Please sign in to comment.