예제 #1
0
func main() {
	shell := ishell.NewShell()

	// display info
	shell.Println("Sample Interactive Shell")

	// handle login
	shell.Register("login", func(args ...string) (string, error) {
		doLogin(shell)
		return "", nil
	})

	// handle "greet".
	shell.Register("greet", func(args ...string) (string, error) {
		name := "Stranger"
		if len(args) > 0 {
			name = strings.Join(args, " ")
		}
		return "Hello " + name, nil
	})

	// read multiple lines with "multi" command
	shell.Register("multi", func(args ...string) (string, error) {
		shell.Println("Input multiple lines and end with semicolon ';'.")
		lines := shell.ReadMultiLines(";")
		shell.Println("Done reading. You wrote:")
		return lines, nil
	})

	// start shell
	shell.Start()
}
예제 #2
0
func main() {

	// create new shell.
	// by default, new shell includes 'exit', 'help' and 'clear' commands.
	shell := ishell.NewShell()

	shell.Println("Nuage API Interactive Shell")

	shell.Register("greet", mygreet)

	shell.Register("debuglevel", debuglevel)

	// API connection handling

	shell.Register("displayconn", displayconn)

	shell.Register("setconn", setconn)

	shell.Register("makeconn", makeconn)

	// Enterprise CRUD operations
	shell.Register("GET", Get)

	shell.Register("CREATE", Create)

	shell.Register("DELETE", Delete)

	// shell.Register("EnterprisesList", EnterprisesList)

	// shell.Register("EnterpriseGet", EnterpriseGet)

	// start shell
	shell.Start()
}