示例#1
0
文件: logview.go 项目: evmar/smash
func NewLogView(parent View, height int) (*LogView, error) {
	lv := &LogView{
		ViewBase: ViewBase{parent},
		rlconfig: readline.NewConfig(),
		height:   height,
	}
	cwd := ""
	bash, err := bash.StartBash()
	if err != nil {
		return nil, err
	}
	lv.shell = shell.NewShell(cwd, nil, bash)
	lv.shell.LoadEnv()
	lv.addEntry()
	return lv, nil
}
示例#2
0
文件: demo.go 项目: evmar/smash
func main() {
	b, err := bash.StartBash()
	if err != nil {
		log.Fatalf("start failed: %s", err)
	}

	s := bufio.NewScanner(os.Stdin)
	for {
		fmt.Printf("text to complete> ")
		if !s.Scan() {
			break
		}
		_, exps, err := b.Complete(s.Text())
		if err != nil {
			log.Fatalf("run failed: %s", err)
		}
		for _, exp := range exps {
			fmt.Printf("  %q\n", exp)
		}
	}
	if err := s.Err(); err != nil {
		log.Fatalf("scan: %s", err)
	}
}