Esempio n. 1
0
func TestNumber(t *testing.T) {
	_, err := Do(cmd.ReadArgs([]string{"someurl.com:1234", "username", "password", "toomany"}))
	if err == nil {
		// Expected error
		t.Fail()
	}
	_, err = Do(cmd.ReadArgs([]string{"someurl.com:1234", "toofew"}))
	if err == nil {
		// Expected error
		t.Fail()
	}

}
Esempio n. 2
0
func expectError(t *testing.T, URL string) {
	_, err := Do(cmd.ReadArgs([]string{URL, "admin", "addmin"}))
	if err == nil {
		t.Fail()
	}

}
Esempio n. 3
0
File: main.go Progetto: m1028639/xld
func main() {

	args, err := cmd.ReadArgs(os.Args[1:])
	if err != nil {
		fmt.Println("ERROR", err)
		os.Exit(1)

	}

	var result string

	finder := commands.Finder()
	command, ok := finder(args.Main())

	if ok {

		if len(args.Subs()) >= command.MinArgs {
			result, err = command.Do(args)
		} else {
			errorText := fmt.Sprintf(
				"Command %s expects at least %d arguments",
				command.Name, command.MinArgs)
			err = errors.New(errorText)
		}
	} else {

		// TODO check update vs upgrade = similar
		// TODO Make list depend on permissions
		// TODO if not logged in or env var; show how

		fmt.Println("XL Deploy Command Line Alternative - EXPERIMENTAL v0.1")
		fmt.Println("Created by Adriaan de Jonge - August, 2014")

		fmt.Println("\nUsage: xld <command> <params...>\n\nCommands\n")

		for _, el := range commands.List() {

			name := el.Name + "              "
			name = name[:12]

			if !el.Hidden {
				fmt.Println(name, "-", el.Description)
			}
		}

		fmt.Println("\nFor additional help on parameters, type: xld help <command>")

	}
	if err != nil {
		fmt.Println("ERROR", err)
		os.Exit(1)
	} else if result != "" {
		fmt.Println(result)
		os.Exit(0)
	}

}