Esempio n. 1
0
func main() {
	createDataDir()
	// Construct the context
	context := api.Context{
		W:        os.Stdout,
		Shells:   shells.Allshells(),
		Commands: commands.Allcommands(),
	}
	argParse(&context)
	if err := context.SetShell(context.Shells[option.shell]); err != nil {
		fmt.Fprintln(context.W, err)
	}
	context.Liner = liner.NewLiner()

	// Execute command if supplied through command-line
	if option.cmdstr != "" {
		if err := doCommand(&context, option.cmdstr); err != nil {
			fmt.Fprintln(context.W, err)
		}
	} else {
		option.interactive = true
	}

	go signalCatcher(&context)
	if option.interactive {
		interactiveLoop(&context)
	}
	(&context).Close()
}