forked from otiai10/cwl.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binding.go
50 lines (48 loc) · 1.33 KB
/
binding.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
package cwl
// Binding represents and combines "CommandLineBinding" and "CommandOutputBinding"
// @see
// - http://www.commonwl.org/v1.0/CommandLineTool.html#CommandLineBinding
// - http://www.commonwl.org/v1.0/CommandLineTool.html#CommandOutputBinding
type Binding struct {
// Common
LoadContents bool
// CommandLineBinding
Position int `json:"position"`
Prefix string `json:"prefix"`
Separate bool `json:"separate"`
Separator string `json:"separator"`
ShellQuote bool `json:"shellQuote"`
ValueFrom *Alias `json:"valueFrom"`
// CommandOutputBinding
Glob []string `json:"glob"`
Eval string `json:"outputEval"`
Contents bool `json:"loadContents"`
}
// New constructs new "Binding".
func (binding Binding) New(i interface{}) *Binding {
dest := new(Binding)
switch x := i.(type) {
case map[string]interface{}:
for key, v := range x {
switch key {
case "position":
dest.Position = int(v.(float64))
case "prefix":
dest.Prefix = v.(string)
case "itemSeparator":
dest.Separator = v.(string)
case "loadContents":
dest.LoadContents = v.(bool)
case "glob":
dest.Glob = StringArrayable(v)
case "shellQuote":
dest.ShellQuote = v.(bool)
case "valueFrom":
dest.ValueFrom = &Alias{v.(string)}
case "outputEval":
dest.Eval = v.(string)
}
}
}
return dest
}