Skip to content

Commit d78b43c

Browse files
James TsaiJames Tsai
authored andcommitted
feat: add hackmd-api flag descriptions
1 parent dfffcbf commit d78b43c

File tree

9 files changed

+53
-21
lines changed

9 files changed

+53
-21
lines changed

src/commands/notes/create.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CommentPermissionType, CreateNoteOptions, NotePermissionRole} from '@hac
22
import {CliUx, Command, Flags} from '@oclif/core'
33

44
import {APIClient} from '../../api'
5+
import {commentPermission, noteContent, notePermission, noteTitle} from '../../flags'
56
import readStdin from '../../read-stdin-stream'
67

78
export default class Create extends Command {
@@ -20,11 +21,11 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
2021

2122
static flags = {
2223
help: Flags.help({char: 'h'}),
23-
title: Flags.string(),
24-
content: Flags.string(),
25-
readPermission: Flags.string(),
26-
writePermission: Flags.string(),
27-
commentPermission: Flags.string(),
24+
title: noteTitle(),
25+
content: noteContent(),
26+
readPermission: notePermission(),
27+
writePermission: notePermission(),
28+
commentPermission: commentPermission(),
2829
...CliUx.ux.table.flags(),
2930
}
3031

src/commands/notes/delete.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {noteId} from '../../flags'
45

56
export default class Delete extends Command {
67
static description = 'Delete a note'
@@ -11,7 +12,7 @@ export default class Delete extends Command {
1112

1213
static flags = {
1314
help: Flags.help({char: 'h'}),
14-
noteId: Flags.string(),
15+
noteId: noteId(),
1516
}
1617

1718
async run() {

src/commands/notes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {CliUx, Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {noteId} from '../../flags'
45

56
export default class IndexCommand extends Command {
67
static description = 'HackMD notes commands'
@@ -14,7 +15,7 @@ raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q n
1415

1516
static flags = {
1617
help: Flags.help({char: 'h'}),
17-
noteId: Flags.string(),
18+
noteId: noteId(),
1819
...CliUx.ux.table.flags(),
1920
}
2021

src/commands/notes/update.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {noteContent, noteId} from '../../flags'
45

56
export default class Update extends Command {
67
static description = 'Update note content'
@@ -11,8 +12,8 @@ export default class Update extends Command {
1112

1213
static flags = {
1314
help: Flags.help({char: 'h'}),
14-
noteId: Flags.string(),
15-
content: Flags.string()
15+
noteId: noteId(),
16+
content: noteContent()
1617
}
1718

1819
async run() {

src/commands/team-notes/create.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CommentPermissionType, CreateNoteOptions, NotePermissionRole} from '@hac
22
import {CliUx, Command, Flags} from '@oclif/core'
33

44
import {APIClient} from '../../api'
5+
import {commentPermission, noteContent, notePermission, noteTitle, teamPath} from '../../flags'
56
import readStdin from '../../read-stdin-stream'
67

78
export default class Create extends Command {
@@ -19,12 +20,12 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
1920

2021
static flags = {
2122
help: Flags.help({char: 'h'}),
22-
teamPath: Flags.string(),
23-
title: Flags.string(),
24-
content: Flags.string(),
25-
readPermission: Flags.string(),
26-
writePermission: Flags.string(),
27-
commentPermission: Flags.string(),
23+
teamPath: teamPath(),
24+
title: noteTitle(),
25+
content: noteContent(),
26+
readPermission: notePermission(),
27+
writePermission: notePermission(),
28+
commentPermission: commentPermission(),
2829
...CliUx.ux.table.flags(),
2930
}
3031

src/commands/team-notes/delete.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {noteId, teamPath} from '../../flags'
45

56
export default class Delete extends Command {
67
static description = 'Delete a team note'
@@ -11,8 +12,8 @@ export default class Delete extends Command {
1112

1213
static flags = {
1314
help: Flags.help({char: 'h'}),
14-
teamPath: Flags.string(),
15-
noteId: Flags.string(),
15+
teamPath: teamPath(),
16+
noteId: noteId(),
1617
}
1718

1819
async run() {

src/commands/team-notes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {CliUx, Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {teamPath} from '../../flags'
45

56
export default class IndexCommand extends Command {
67
static description = 'HackMD team-notes commands'
@@ -15,7 +16,7 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test`,
1516

1617
static flags = {
1718
help: Flags.help({char: 'h'}),
18-
teamPath: Flags.string(),
19+
teamPath: teamPath(),
1920
...CliUx.ux.table.flags(),
2021
}
2122

src/commands/team-notes/update.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Command, Flags} from '@oclif/core'
22

33
import {APIClient} from '../../api'
4+
import {noteContent, noteId, teamPath} from '../../flags'
45

56
export default class Update extends Command {
67
static description = 'Update team note content'
@@ -11,9 +12,9 @@ export default class Update extends Command {
1112

1213
static flags = {
1314
help: Flags.help({char: 'h'}),
14-
teamPath: Flags.string(),
15-
noteId: Flags.string(),
16-
content: Flags.string()
15+
teamPath: teamPath(),
16+
noteId: noteId(),
17+
content: noteContent()
1718
}
1819

1920
async run() {

src/flags.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {Flags} from '@oclif/core'
2+
export const noteId = Flags.build({
3+
description: 'hackmd note id'
4+
})
5+
6+
export const teamPath = Flags.build({
7+
description: 'hackmd team path'
8+
})
9+
10+
export const noteContent = Flags.build({
11+
description: 'new note content'
12+
})
13+
14+
export const noteTitle = Flags.build({
15+
description: 'new note title'
16+
})
17+
18+
export const notePermission = Flags.build({
19+
description: 'set note permission: owner, signed_in, guest'
20+
})
21+
22+
export const commentPermission = Flags.build({
23+
description: 'set comment permission: disabled, forbidden, owners, signed_in_users, everyone'
24+
})

0 commit comments

Comments
 (0)