diff --git a/commands.go b/commands.go index c3cda8c..28e831e 100644 --- a/commands.go +++ b/commands.go @@ -104,7 +104,7 @@ the last argument, init, is a function that will be called by mow.cli to further (sub) command, e.g. to add options, arguments and the code to execute */ func (c *Cmd) Command(name, desc string, init CmdInitializer) { - aliases := strings.Split(name, " ") + aliases := strings.Fields(name) c.commands = append(c.commands, &Cmd{ ErrorHandling: c.ErrorHandling, name: aliases[0], @@ -389,7 +389,7 @@ func (c *Cmd) formatDescription(desc, envVar string) string { if len(envVar) > 0 { b.WriteString(" (") sep := "" - for _, envVal := range strings.Split(envVar, " ") { + for _, envVal := range strings.Fields(envVar) { b.WriteString(fmt.Sprintf("%s$%s", sep, envVal)) sep = " " } diff --git a/options.go b/options.go index 3f4ed9c..7d12226 100644 --- a/options.go +++ b/options.go @@ -256,15 +256,15 @@ func (o *opt) String() string { } func mkOptStrs(optName string) []string { - namesSl := strings.Split(optName, " ") - for i, name := range namesSl { + res := strings.Fields(optName) + for i, name := range res { prefix := "-" if len(name) > 1 { prefix = "--" } - namesSl[i] = prefix + name + res[i] = prefix + name } - return namesSl + return res } func (c *Cmd) mkOpt(opt opt) {