-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yaml
154 lines (141 loc) · 4.78 KB
/
config.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
cog_bundle_version: 4
name: format
description: Pipeline output formatting utilities
version: 0.5.0
docker:
image: cogcmd/format
tag: 0.5.0
commands:
head:
executable: "/home/bundle/cog-command"
description: Pass through only the first N results. Defaults to 10 results."
arguments: "[count]"
rules:
- allow
fields:
executable: "/home/bundle/cog-command"
description: List the fields in an input object
long_description: |
Returns a sorted list of all the top-level keys in an input
object.
Returns nothing if run without input (e.g., at the beginning of
a pipeline).
rules:
- allow
list:
description: Build list of values from pipeline input
long_description: |
Builds a string representation of a list of values from pipeline input
with each item separated by a customizable delimiter.
executable: "/home/bundle/cog-command"
options:
order:
description: 'Sort order for list. Allowed values are: asc, desc'
type: string
required: false
short_flag: o
join:
description: Delimiter to use between list items. Default is ", "
type: string
required: false
short_flag: j
rules:
- allow
pluck:
executable: "/home/bundle/cog-command"
description: Return a nested object from the input
arguments: "<path>"
options:
as:
description: Return results in a field named with the value of this option
type: string
required: false
rules:
- allow
table:
description: Generate a table from pipeline output
executable: "/home/bundle/cog-command"
arguments: field1 field2 ... fieldN
documentation: |
Each field is taken to be a key that should be extracted from an
input map.
When the field is a string like "foo", this means "select the
value of the 'foo' key".
Alternatively, a path can be provided, as in "foo.bar.baz". This
will produce a column named "baz", with values found at that key
path. For instance, when run on the object
{"foo": {"bar": {"baz": "hello world"}}}
the string "foo.bar.baz" will extract the value
"hello world".
Fields may be renamed, as well. Passing a quoted string like
"foo=bar" will produce a column labeled "foo", with the value of
the "bar" key. Paths can be renamed in the same way, if desired
(e.g. "foo=foo.bar.baz"). Note that these pairs *must* be quoted
to parse correctly.
If such a column name transformation will result in a duplicate
name, the full keypath will be used instead.
However, these conventions mean that this command may not
operate well on fields that contain "=" or "." characters.
examples: |
seed '[{"foo": "hello", "bar": "world"},
{"foo": "hola", "bar": "mundo"}]'
| format:table foo bar
+-------+-------+
| foo | bar |
+-------+-------+
| hello | world |
| hola | mundo |
+-------+-------+
seed '[{"foo": "hello", "bar": "world"},
{"foo": "hola", "bar": "mundo"}]'
| format:table "key=foo" "value=bar"
+-------+-------+
| key | value |
+-------+-------+
| hello | world |
| hola | mundo |
+-------+-------+
seed '[{"foo": {"greeting": "hello", "valediction": "good-bye"}, "bar": "world"},
{"foo": {"greeting": "hola", "valediction": "adios"}, "bar": "mundo"}]'
| format:table foo.greeting bar
+----------+-------+
| greeting | bar |
+----------+-------+
| hello | world |
| hola | mundo |
+----------+-------+
seed '[{"foo": {"greeting": "hello", "valediction": "good-bye"}, "bar": "world"},
{"foo": {"greeting": "hola", "valediction": "adios"}, "bar": "mundo"}]'
| format:table "farwell=foo.valediction" bar
+----------+-------+
| farwell | bar |
+----------+-------+
| good-bye | world |
| adios | mundo |
+----------+-------+
seed '[{"foo": {"bar": "inside"}, "bar": "outside"},
{"foo": {"bar": "also inside"}, "bar": "also outside"}]'
| format:table bar foo.bar
+--------------+-------------+
| bar | foo.bar |
+--------------+-------------+
| outside | inside |
| also outside | also inside |
+--------------+-------------+
rules:
- allow
tail:
executable: "/home/bundle/cog-command"
description: Pass through only the last N results. Defaults to 10 results.
arguments: "[count]"
rules:
- allow
templates:
preformatted:
body: |
```
~$results[0].body~
```
fields:
body: "**Fields:** ~join var=$results[0].fields~~$item~~end~\n"