Esempio n. 1
0
File: repl.go Progetto: mytchel/pass
func RunRepl(store *Secstore) {
	var sections []string
	var line string
	var err error

	liner := liner.NewLiner()
	defer liner.Close()

	liner.SetCompleter(completer)

	for {
		line, err = liner.Prompt("> ")
		if err != nil {
			break
		}

		liner.AppendHistory(line)

		sections = splitSections(line)

		if len(sections) == 0 {

		} else if strings.HasPrefix("quit", sections[0]) {
			break
		} else {
			err = EvalCommand(store, sections)
			if err != nil {
				fmt.Fprintln(os.Stderr, err)
			}
		}
	}

	fmt.Fprintln(os.Stderr, "Exiting...")
}
Esempio n. 2
0
// NewDebugger creates a debugger.
// Be sure to defer a call to Debugger.Shutdown() afterwards, or your terminal
// will be left in a broken state.
func NewDebugger(cpu *cpu.Cpu, debugFile string) *Debugger {
	var symbols debugSymbols
	if len(debugFile) > 0 {
		var err error
		symbols, err = readDebugSymbols(debugFile)
		if err != nil {
			panic(err)
		}
	}

	liner := liner.NewLiner()
	liner.SetCompleter(linerCompleter(symbols))

	return &Debugger{
		liner:   liner,
		cpu:     cpu,
		symbols: symbols,
	}
}