// Run the console. func Console(config core.Config) (err error) { fmt.Printf(` [1;32mWelcome to the Gate administration console![0m [32mGate Copyright (C) 2012-2015 Cyril Adrian <*****@*****.**> This program comes with ABSOLUTELY NO WARRANTY; for details type [33mshow w[32m. This is free software, and you are welcome to redistribute it under certain conditions; type [33mshow c[32m for details.[0m Type [33mhelp[0m for details on available options. Just hit [33m<enter>[0m to exit. `) srv, err := proxy(config) if err != nil { return } remoter := remote.NewRemoter(srv, config) if err != nil { return } mmi, err := ui.Ui(srv, config) if err != nil { return } commander, err := commands.NewCommander(remoter, srv, config, mmi) if err != nil { return } state := liner.NewLiner() defer state.Close() rl := &readline{ commander: commander, server: srv, state: state, } complete := func(line string) (result []string) { result, err := rl.complete(line) if err != nil { fmt.Println(err) return } return } state.SetCompleter(complete) e := rl.loop(config) if e != io.EOF { err = e } return }
// Run the console. func CommandLine(config core.Config) (err error) { srv, err := proxy(config) if err != nil { return } remoter := remote.NewRemoter(srv, config) if err != nil { return } mmi, err := ui.Ui(srv, config) if err != nil { return } commander, err := commands.NewCommander(remoter, srv, config, mmi) if err != nil { return } cmd := commander.Command(os.Args[2]) if cmd == nil { cmd = commander.Default() } err = cmd.Run(os.Args[2:]) return }