func ValidateInput()

in src/ssmclicommands/inputhandler.go [89:125]


func ValidateInput(args []string, out io.Writer) {
	uuid.SwitchFormat(uuid.CleanHyphen)

	if len(args) < ArgumentLength {
		utils.DisplayCommandUsage(out)
		return
	}

	err, _, command, subcommand, parameters := ParseCliCommand(args)

	if err != nil {
		utils.DisplayCommandUsage(out)
		fmt.Fprint(out, err.Error())
		return
	}

	if cmd, exists := utils.SsmCliCommands[command]; exists {
		if utils.IsHelp(subcommand, parameters) {
			fmt.Fprintln(out, cmd.Help())
		} else {
			cmdErr, result := cmd.Execute(parameters)
			if cmdErr != nil {
				utils.DisplayCommandUsage(out)
				fmt.Fprint(out, cmdErr.Error())
				return
			} else {
				fmt.Fprint(out, result)
			}
		}
	} else if command == utils.HelpFlag {
		utils.DisplayHelp(out)
	} else {
		utils.DisplayCommandUsage(out)
		fmt.Fprintf(out, "\nInvalid command %v.  The following commands are supported:\n\n", command)
		utils.DisplaySupportedCommands(out)
	}
}