-
Notifications
You must be signed in to change notification settings - Fork 3
/
cogs.ts
57 lines (51 loc) · 1.43 KB
/
cogs.ts
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
import {cli} from 'cli-ux'
import RegistryAwareCommand from '../../registry-aware-command'
export class Cogs extends RegistryAwareCommand {
static description = 'List Cogs that are currently installed on this machine'
static examples = [
'$ crank registry:cogs',
'$ crank registry:cogs --extended --no-truncate'
]
static flags = {
...cli.table.flags()
}
async run() {
const {flags} = this.parse(Cogs)
flags.sort = flags.sort || 'name'
const registry = this.registry.buildCogRegistry()
cli.table(registry, {
label: {},
name: {
minWidth: 30,
},
version: {},
type: {
get: row => row._runConfig && row._runConfig.strategy
},
stepCount: {
header: 'Steps',
get: row => row.stepDefinitionsList && row.stepDefinitionsList.length,
extended: true
},
authFields: {
header: 'Auth Fields',
get: row => row.authFieldsList && row.authFieldsList.map(field => field.key).join('\n'),
extended: true
},
startCmd: {
header: 'Start Command',
extended: true,
get: row => {
if (row._runConfig && row._runConfig.strategy === 'docker') {
return `docker run --rm ${row._runConfig.dockerImage}`
} else {
return row._runConfig ? row._runConfig.cmd : ''
}
}
}
}, {
printLine: this.log,
...flags
})
}
}