-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheval.go
51 lines (43 loc) · 951 Bytes
/
eval.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
49
50
51
package main
import (
"fmt"
"os"
"github.com/d3media/llconf/compiler"
)
var eval = &Command{
Name: "eval",
Usage: "eval [input_folder]",
Run: evalRun,
}
var run_cfg struct {
input string
promise string
verbose bool
dryrun bool
}
func init() {
eval.Flag.StringVar(&run_cfg.promise, "promise", "done", "the promise that will be used as root")
}
func evalRun(args []string) {
switch len(args) {
case 0:
fmt.Println("no input folder specified")
os.Exit(1)
case 1:
run_cfg.input = args[0]
default:
fmt.Fprintf(os.Stderr, "argument count mismatch")
os.Exit(1)
}
promises, err := compiler.Compile(run_cfg.input)
if err != nil {
fmt.Fprintf(os.Stderr, "error while parsing input: %v\n", err)
return
}
_, promise_present := promises[run_cfg.promise]
if !promise_present {
fmt.Fprintf(os.Stderr, "specified goal (%s) not found in config\n", run_cfg.promise)
return
}
fmt.Println("evaluation successful")
}