/
cmds.go
70 lines (57 loc) · 1.43 KB
/
cmds.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"strconv"
"strings"
"github.com/sbinet/paw-go/pkg/gribble"
"github.com/sbinet/paw-go/pkg/pawmgr"
)
// A Gribble environment is composed of Go struct types. Since the environment
// does not care about values, zero values of each command struct can be
// used in the gribble.Command slice.
//
// Note that these may also be specified as non-pointers.
var env *gribble.Environment = gribble.New(
[]gribble.Command{
new_cmd_ntuple_create(),
new_cmd_ntuple_plot(),
},
)
func new_cmd_ntuple_create() *ntuple_create {
return &ntuple_create{
//mgr: nil,
}
}
type ntuple_create struct {
name string `/ntuple/create`
Id int `param:"1" types:"int"`
Title string `param:"2" types:"string"`
Vars string `param:"3" types:"string"`
mgr *pawmgr.NtupleMgr
}
func (cmd *ntuple_create) Run() gribble.Value {
id := cmd.Id
title,err := strconv.Unquote(cmd.Title)
if err != nil {
return err
}
//nvars := cmd.Nvars.(int)
vars, err := strconv.Unquote(cmd.Vars)
ntvars := strings.Split(vars, ",")
return cmd.mgr.Create(id, title, ntvars)
}
func new_cmd_ntuple_plot() *ntuple_plot {
return &ntuple_plot{
//mgr: nil,
}
}
type ntuple_plot struct {
name string `/ntuple/plot`
Id int `param:"1" types:"int"`
//Func string `param:"2" types:"string"`
//Vars string `param:"3" types:"string"`
mgr *pawmgr.NtupleMgr
}
func (cmd *ntuple_plot) Run() gribble.Value {
id := cmd.Id
return cmd.mgr.Plot(id)
}