-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.ts
More file actions
57 lines (52 loc) · 1.76 KB
/
Copy pathindex.ts
File metadata and controls
57 lines (52 loc) · 1.76 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
56
57
import {Flags, ux} from '@oclif/core'
import HackMDCommand from '../../command'
import {folderId} from '../../flags'
export default class IndexCommand extends HackMDCommand {
static description = 'HackMD folders commands'
static examples = [
`$ hackmd-cli folders
ID Color Description Icon Name Parent Folder ID
──────────────────────────────────── ─────── ───────────────────── ───── ─────────── ────────────────────────────────────
91722050-bf47-4334-9e5d-87125a724c29 #4F46E5 Project documentation 1F600 engineering fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c`,
]
static flags = {
folderId,
help: Flags.help({char: 'h'}),
...ux.table.flags(),
}
async run() {
const {flags} = await this.parse(IndexCommand)
try {
const APIClient = await this.getAPIClient()
const folders = flags.folderId ? [await APIClient.getFolder(flags.folderId)] : await APIClient.getFolderList()
ux.table(
folders,
Object.fromEntries([
[
'id',
{
header: 'ID',
},
],
['color', {}],
['description', {}],
['icon', {}],
['name', {}],
[
'parentFolderId',
{
header: 'Parent Folder ID',
},
],
]),
{
printLine: this.log.bind(this),
...flags,
},
)
} catch (error) {
this.log('Fetch folders failed')
this.error(error as Error)
}
}
}