-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhistory.ts
48 lines (41 loc) · 1.38 KB
/
history.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
import {Flags, ux} from '@oclif/core'
import HackMDCommand from '../command'
export default class History extends HackMDCommand {
static description = 'List user browse history'
static examples = [
`$ hackmd-cli history
ID Title User Path Team Path
────────────────────── ──────────────────────────────── ────────────────────── ────────
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null
BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test `,
]
static flags = {
help: Flags.help({char: 'h'}),
...ux.table.flags(),
}
async run() {
const {flags} = await this.parse(History)
try {
const APIClient = await this.getAPIClient()
const history = await APIClient.getHistory()
ux.table(history, {
id: {
header: 'ID',
},
title: {},
userPath: {
header: 'User Path',
},
teamPath: {
header: 'Team Path',
},
}, {
printLine: this.log.bind(this),
...flags,
})
} catch (error) {
this.log('Fetch history failed')
this.error(error as Error)
}
}
}