-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbinding.go
55 lines (53 loc) · 1.62 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
51
52
53
54
55
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 *Eval `json:"outputEval"`
Contents bool `json:"loadContents"`
}
// New constructs new "Binding".
func (binding Binding) New(i interface{}) *Binding {
dest := new(Binding)
dest.ShellQuote = true // default value according to CWL spec
dest.Separator = "NOT SPECIFIED" // assigning this default value so "" is not the empty value
dest.Separate = true // default value according to CWL spec
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 "separate":
dest.Separate = v.(bool)
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 = &Eval{v.(string)}
}
}
}
return dest
}