-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.ts
More file actions
55 lines (49 loc) · 1.57 KB
/
index.ts
File metadata and controls
55 lines (49 loc) · 1.57 KB
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
import {Flags, ux} from '@oclif/core'
import HackMDCommand from '../../command'
import {teamPath} from '../../flags'
export default class IndexCommand extends HackMDCommand {
static description = 'HackMD team-notes commands'
static examples = [
`$ hackmd-cli team-notes --teamPath=CLI-test
ID Title User path Team path
────────────────────── ──────────────────────────────── ──────── ────────
WNkLM6gkS0Cg2cQ8rv7bYA a team note null CLI-test
BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test`,
]
static flags = {
help: Flags.help({char: 'h'}),
teamPath,
...ux.table.flags(),
}
async run() {
const {flags} = await this.parse(IndexCommand)
if (!flags.teamPath) {
this.error('Flag teamPath could not be empty')
}
try {
const APIClient = await this.getAPIClient()
const notes = await APIClient.getTeamNotes(flags.teamPath)
ux.table(notes, {
id: {
header: 'ID',
},
tags: {
get: row => (row.tags ?? []).join(', '),
},
teamPath: {
header: 'Team path',
},
title: {},
userPath: {
header: 'User path',
},
}, {
printLine: this.log.bind(this),
...flags,
})
} catch (error) {
this.log('Fetch team notes failed')
this.error(error as Error)
}
}
}