Esempio n. 1
0
func New(args []string) *cli {
	if len(args) > 1 {
		return nil
	}

	// We assume the terminal starts in cooked mode.
	cooked, _ = liner.TerminalMode()
	if cooked == nil {
		return nil
	}

	i := &cli{liner.NewLiner()}

	if history_path, err := task.GetHistoryFilePath(); err == nil {
		if f, err := os.Open(history_path); err == nil {
			i.ReadHistory(f)
			f.Close()
		}
	}

	uncooked, _ = liner.TerminalMode()

	i.SetCtrlCAborts(true)
	i.SetTabCompletionStyle(liner.TabPrints)
	i.SetWordCompleter(complete)

	return i
}
Esempio n. 2
0
func (i *cli) Close() error {
	if i.Exists() {
		if history_path, err := task.GetHistoryFilePath(); err == nil {
			if f, err := os.Create(history_path); err == nil {
				i.WriteHistory(f)
				f.Close()
			}
		}
	}
	return i.State.Close()
}
Esempio n. 3
0
File: ui.go Progetto: scauios/oh
func (i *cli) Close() error {
	if i.Exists() {
		if history_path, err := task.GetHistoryFilePath(); err == nil {
			if f, err := os.Create(history_path); err == nil {
				i.WriteHistory(f)
				f.Close()
			} else {
				println("Error writing history: " + err.Error())
			}
		}
	}
	return i.State.Close()
}