Skip to content

Commit f56db22

Browse files
James TsaiJames Tsai
authored andcommitted
feat: add v1-api's teams command
1 parent 305cab5 commit f56db22

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

src/commands/teams.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
import {Command, flags} from '@oclif/command'
2-
import cli from 'cli-ux'
3-
1+
import {Command, Flags, CliUx } from '@oclif/core'
42
import {APIClient} from '../api'
53

64
export default class Teams extends Command {
7-
static description = 'HackMD Teams Command'
5+
static description = 'List teams'
86

97
static examples = [
108
`$ hackmd-cli teams
11-
12-
Path Name
13-
team1 Team 1
14-
my-awesome-team My Awesome Team`,
9+
ID Name Path Owner ID
10+
──────────────────────────────────── ───────────── ──────── ────────────────────────────────────
11+
f76308a6-d77a-41f6-86d0-8ada426a6fb4 CLI test team CLI-test 82f7f3d9-4079-4c78-8a00-14094272ece9 `,
1512
]
1613

1714
static flags = {
18-
help: flags.help({char: 'h'}),
19-
...cli.table.flags()
15+
help: Flags.help({char: 'h'}),
16+
...CliUx.ux.table.flags(),
2017
}
2118

2219
async run() {
23-
if (!APIClient.enterprise) {
24-
return this.log('Teams command only works on HackMD EE instance')
25-
}
26-
20+
const {flags} = await this.parse(Teams)
21+
2722
try {
28-
const teams = await APIClient.getTeams()
23+
const notes = await APIClient.getTeams()
2924

30-
cli.table(teams, {
31-
path: {
32-
header: 'Path',
25+
CliUx.ux.table(notes, {
26+
id: {
27+
header: 'ID',
3328
},
34-
name: {}
29+
name:{},
30+
path: {},
31+
ownerId: {
32+
header: 'Owner ID'
33+
}
3534
}, {
36-
printLine: this.log,
35+
printLine: this.log.bind(this),
3736
...flags
3837
})
39-
} catch (err) {
38+
} catch (e) {
4039
this.log('Fetch teams failed')
41-
this.error(err)
40+
this.error(e)
4241
}
4342
}
4443
}

0 commit comments

Comments
 (0)