-
Notifications
You must be signed in to change notification settings - Fork 275
/
repl.go
48 lines (39 loc) · 888 Bytes
/
repl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the Apache version 2.0 license. See LICENSE file for terms.
package zmscli
import (
"github.com/boynton/repl"
)
func (cli *Zms) Eval(expr string) (string, bool, error) {
if expr == "" {
return "", false, nil
}
params, err := cli.tokenizer(expr)
if err != nil {
return "", false, err
}
result, err := cli.EvalCommand(params)
if result == nil || err != nil {
return "", false, err
}
return *result, false, err
}
func (cli *Zms) Prompt() string {
red := "\033[0;31m"
black := "\033[0;0m"
return red + cli.Domain + "> " + black
}
func (cli *Zms) Reset() {
}
func (cli *Zms) Complete(expr string) (string, []string) {
return "", nil
}
func (cli *Zms) Start() []string {
return nil
}
func (cli *Zms) Stop(history []string) {
}
func (cli *Zms) Repl() (*string, error) {
repl.REPL(cli)
return nil, nil
}