Skip to content

Commit 3c2c2d3

Browse files
committed
List team command
1 parent aff336f commit 3c2c2d3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/commands/teams.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {Command, flags} from '@oclif/command'
2+
import cli from 'cli-ux'
3+
4+
import {APIClient} from '../api'
5+
6+
export default class Teams extends Command {
7+
static description = 'HackMD Teams Command'
8+
9+
static examples = [
10+
`$ hackmd-cli teams
11+
12+
Path Name
13+
team1 Team 1
14+
my-awesome-team My Awesome Team`,
15+
]
16+
17+
static flags = {
18+
help: flags.help({char: 'h'}),
19+
...cli.table.flags()
20+
}
21+
22+
async run() {
23+
if (!APIClient.enterprise) {
24+
return this.log('Teams command only works on HackMD EE instance')
25+
}
26+
27+
try {
28+
const teams = await APIClient.getTeams()
29+
30+
cli.table(teams, {
31+
path: {
32+
header: 'Path',
33+
},
34+
name: {}
35+
}, {
36+
printLine: this.log,
37+
...flags
38+
})
39+
} catch (err) {
40+
this.log('Fetch teams failed')
41+
this.error(err)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)