-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.ts
More file actions
50 lines (45 loc) · 1.49 KB
/
index.ts
File metadata and controls
50 lines (45 loc) · 1.49 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
import {Flags, ux} from '@oclif/core'
import HackMDCommand from '../../command'
import {noteId} from '../../flags'
export default class IndexCommand extends HackMDCommand {
static description = 'HackMD notes commands'
static examples = [
`$ hackmd-cli notes
ID Title User Path Team Path
────────────────────── ──────────────────────────────── ────────────────────── ────────
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null `,
]
static flags = {
help: Flags.help({char: 'h'}),
noteId,
...ux.table.flags(),
}
async run() {
const {flags} = await this.parse(IndexCommand)
try {
const APIClient = await this.getAPIClient()
const notes = flags.noteId ? [await APIClient.getNote(flags.noteId)] : await APIClient.getNoteList()
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 user notes failed')
this.error(error as Error)
}
}
}