forked from otiai10/cwl.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.go
69 lines (63 loc) · 1.35 KB
/
entry.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 cwl
// Entry represents fs entry, it means [File|Directory|Dirent]
type Entry struct {
Class string
Location string
Path string
Basename string
File
Directory
Dirent
}
// File represents file entry.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#File
type File struct {
Dirname string
Size int64
Format string
}
// Directory represents direcotry entry.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#Directory
type Directory struct {
Listing []Entry
}
// Dirent represents ?
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#Dirent
type Dirent struct {
Entry string
EntryName string
Writable bool
}
// NewList constructs a list of Entry from interface
func (_ Entry) NewList(i interface{}) []Entry {
dest := []Entry{}
switch x := i.(type) {
case string:
dest = append(dest, Entry{}.New(x))
case []interface{}:
for _, v := range x {
dest = append(dest, Entry{}.New(v))
}
}
return dest
}
// New constructs an Entry from interface
func (_ Entry) New(i interface{}) Entry {
dest := Entry{}
switch x := i.(type) {
case string:
dest.Location = x
case map[string]interface{}:
for key, v := range x {
switch key {
case "entryname":
dest.EntryName = v.(string)
case "entry":
dest.Entry = v.(string)
case "writable":
dest.Writable = v.(bool)
}
}
}
return dest
}