File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Command , flags } from '@oclif/command'
2
+ import cli from 'cli-ux'
3
+
4
+ import { APIClient } from '../api'
5
+
6
+ export default class History extends Command {
7
+ static description = 'List notes'
8
+
9
+ static examples = [
10
+ `$ hackmd-cli list
11
+
12
+ ID Name
13
+ A58r8ehYTlySO94oiC_MUA Note1
14
+ EeNHDGocSTi70ytMMGQaaQ Note2` ,
15
+ ]
16
+
17
+ static flags = {
18
+ help : flags . help ( { char : 'h' } ) ,
19
+ team : flags . string ( {
20
+ char : 't' ,
21
+ description : 'team name' ,
22
+ } ) ,
23
+ ...cli . table . flags ( ) ,
24
+ }
25
+
26
+ async run ( ) {
27
+ const { flags} = this . parse ( History )
28
+
29
+ try {
30
+ let notes
31
+ if ( flags . team ) {
32
+ notes = await APIClient . listTeamNotes ( flags . team )
33
+ } else {
34
+ notes = await APIClient . listNotes ( )
35
+ }
36
+
37
+ cli . table ( notes , {
38
+ id : {
39
+ header : 'ID' ,
40
+ } ,
41
+ name : {
42
+ get : row => ( row as any ) . title
43
+ }
44
+ } , {
45
+ printLine : this . log ,
46
+ ...flags
47
+ } )
48
+ } catch ( e ) {
49
+ this . log ( 'Fetch history failed' )
50
+ this . error ( e as string )
51
+ }
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments