func (c *Command) OtherArgs() []string {
	return c.flags.Args()
}
OtherArgs - Returns the non-flag arguments passed to the subcommand. NOTE: This should only be called within the context of an action.
package clir
import (
	"flag"
	"fmt"
	"os"
	"strings"
)
type Command struct {
	name              string
	commandPath       string
	shortdescription  string
	longdescription   string
	subCommands       []*Command
	subCommandsMap    map[string]*Command
	longestSubcommand int
	actionCallback    Action
	app               *Cli
	flags             *flag.FlagSet
	flagCount         int
	helpFlag          bool
	hidden            bool
}
func NewCommand(name string, description string) *Command {
	result := &Command{
		name:             name,
		shortdescription: description,
		subCommandsMap:   make(map[string]*Command),
		hidden:           false,
	}
	return result
}
func (c *Command) setParentCommandPath(parentCommandPath string) {
	if parentCommandPath != "" {
		c.commandPath += parentCommandPath + " "
	}
	c.commandPath += c.name
	c.flags = flag.NewFlagSet(c.commandPath, flag.ContinueOnError)
	c.BoolFlag("help", "Get help on the '"+strings.ToLower(c.commandPath)+"' command.", &c.helpFlag)
}
func (c *Command) setApp(app *Cli) {
	c.app = app
}
func (c *Command) parseFlags(args []string) error {
	tmp := os.Stderr
	os.Stderr = nil
	err := c.flags.Parse(args)
	os.Stderr = tmp
	return err
}
func (c *Command) run(args []string) error {
	if len(args) > 0 {
		subcommand := c.subCommandsMap[args[0]]
		if subcommand != nil {
			return subcommand.run(args[1:])
		}
		err := c.parseFlags(args)
		if err != nil {
			if c.app.errorHandler != nil {
				return c.app.errorHandler(c.commandPath, err)
			}
			return fmt.Errorf("Error: %s\nSee '%s --help' for usage", err, c.commandPath)
		}
		if c.helpFlag {
			c.PrintHelp()
			return nil
		}
	}
	if c.actionCallback != nil {
		return c.actionCallback()
	}
	if c.app.defaultCommand != nil {
		if c.app.defaultCommand != c {
			if len(args) == 0 {
				return c.app.defaultCommand.run(args)
			}
		}
	}
	c.PrintHelp()
	return nil
}
func (c *Command) Action(callback Action) *Command {
	c.actionCallback = callback
	return c
}
func (c *Command) PrintHelp() {
	c.app.PrintBanner()
	commandTitle := c.commandPath
	if c.shortdescription != "" {
		commandTitle += " - " + c.shortdescription
	}
	if c.commandPath != c.name {
		fmt.Println(commandTitle)
	}
	if c.longdescription != "" {
		fmt.Println(c.longdescription + "\n")
	}
	if len(c.subCommands) > 0 {
		fmt.Println("Available commands:")
		fmt.Println("")
		for _, subcommand := range c.subCommands {
			if subcommand.isHidden() {
				continue
			}
			spacer := strings.Repeat(" ", 3+c.longestSubcommand-len(subcommand.name))
			isDefault := ""
			if subcommand.isDefaultCommand() {
				isDefault = "[default]"
			}
			fmt.Printf("   %s%s%s %s\n", subcommand.name, spacer, subcommand.shortdescription, isDefault)
		}
		fmt.Println("")
	}
	if c.flagCount > 0 {
		fmt.Println("Flags:")
		fmt.Println()
		c.flags.SetOutput(os.Stdout)
		c.flags.PrintDefaults()
		c.flags.SetOutput(os.Stderr)
	}
	fmt.Println()
}
func (c *Command) isDefaultCommand() bool {
	return c.app.defaultCommand == c
}
func (c *Command) isHidden() bool {
	return c.hidden
}
func (c *Command) Hidden() {
	c.hidden = true
}
func (c *Command) NewSubCommand(name, description string) *Command {
	result := NewCommand(name, description)
	c.AddCommand(result)
	return result
}
func (c *Command) AddCommand(command *Command) {
	command.setApp(c.app)
	command.setParentCommandPath(c.commandPath)
	name := command.name
	c.subCommands = append(c.subCommands, command)
	c.subCommandsMap[name] = command
	if len(name) > c.longestSubcommand {
		c.longestSubcommand = len(name)
	}
}
func (c *Command) BoolFlag(name, description string, variable *bool) *Command {
	c.flags.BoolVar(variable, name, *variable, description)
	c.flagCount++
	return c
}
func (c *Command) StringFlag(name, description string, variable *string) *Command {
	c.flags.StringVar(variable, name, *variable, description)
	c.flagCount++
	return c
}
func (c *Command) IntFlag(name, description string, variable *int) *Command {
	c.flags.IntVar(variable, name, *variable, description)
	c.flagCount++
	return c
}
func (c *Command) LongDescription(longdescription string) *Command {
	c.longdescription = longdescription
	return c
}