func ParseArgs(args []string) (parsed *SubCommandArgs, err string) {

	// if we have no arguments, that is an error
	count := len(args)
	if count == 0 {
		err = constants.StringNeedOneArgument
		return
	}

	// if the first argument is help, everything else is ignroed
	head := args[0]

	// if the first argument is help, return help
	if head == helpLiteralForm || head == helpShortForm || head == helpLongForm {
		parsed = &SubCommandArgs{
			Help: true,
			args: args[1:],
		}
		return
	}

	if head == versionLiteralForm || head == versionShortForm || head == versionLongForm {
		parsed = &SubCommandArgs{
			Version: true,
			args:    args[1:],
		}
		return
	}

	if head == forLiteralForm || head == forShortForm || head == forLongForm {
		// gg for $pattern $command
		if count < 3 {
			err = constants.StringNeedTwoAfterFor
			return
		}

		parsed = &SubCommandArgs{
			Command: args[2],
			Pattern: args[1],
			args:    args[3:],
		}
		return
	}

	// gg $pattern $command
	parsed = &SubCommandArgs{
		Command: args[0],
		args:    args[1:],
	}
	return
}
// ParseArgs parses arguments from the command line
ParseArgs parses arguments from the command line
// ParseArgs parses arguments from the command line
func ParseArgs(args []string) (parsed *SubCommandArgs, err string) {
	count := len(args)
	if count == 0 {
		err = constants.StringNeedOneArgument
		return
	}
	head := args[0]
	if head == helpLiteralForm || head == helpShortForm || head == helpLongForm {
		parsed = &SubCommandArgs{
			Help: true,
			args: args[1:],
		}
		return
	}
	if head == versionLiteralForm || head == versionShortForm || head == versionLongForm {
		parsed = &SubCommandArgs{
			Version: true,
			args:    args[1:],
		}
		return
	}
	if head == forLiteralForm || head == forShortForm || head == forLongForm {
		if count < 3 {
			err = constants.StringNeedTwoAfterFor
			return
		}
		parsed = &SubCommandArgs{
			Command: args[2],
			Pattern: args[1],
			args:    args[3:],
		}
		return
	}
	parsed = &SubCommandArgs{
		Command: args[0],
		args:    args[1:],
	}
	return
}
func ParseArgs ( args [ ] string ) ( parsed * SubCommandArgs , err string ) { count := len ( args ) if count == 0 { err = constants . StringNeedOneArgument return } head := args [ 0 ] if head == helpLiteralForm || head == helpShortForm || head == helpLongForm { parsed = & SubCommandArgs { Help : true , args : args [ 1 : ] , } return } if head == versionLiteralForm || head == versionShortForm || head == versionLongForm { parsed = & SubCommandArgs { Version : true , args : args [ 1 : ] , } return } if head == forLiteralForm || head == forShortForm || head == forLongForm { if count < 3 { err = constants . StringNeedTwoAfterFor return } parsed = & SubCommandArgs { Command : args [ 2 ] , Pattern : args [ 1 ] , args : args [ 3 : ] , } return } parsed = & SubCommandArgs { Command : args [ 0 ] , args : args [ 1 : ] , } return }
ParseArgs parses arguments from the command line
ParseArgs parses arguments from the command line
// if we have no arguments, that is an error // if the first argument is help, everything else is ignroed // if the first argument is help, return help // gg for $pattern $command // gg $pattern $command