-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathupdate.ts
More file actions
35 lines (28 loc) · 865 Bytes
/
update.ts
File metadata and controls
35 lines (28 loc) · 865 Bytes
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
import {Flags} from '@oclif/core'
import HackMDCommand from '../../command'
import {noteContent, noteId} from '../../flags'
export default class Update extends HackMDCommand {
static description = 'Update note content'
static examples = [
"$ hackmd-cli notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --content='# A new title'"
]
static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId(),
content: noteContent()
}
async run() {
const {flags} = await this.parse(Update)
const {noteId, content} = flags
if (!noteId) {
this.error('Flag noteId could not be empty')
}
try {
const APIClient = await this.getAPIClient()
await APIClient.updateNoteContent(noteId, content)
} catch (e) {
this.log('Update note content failed')
this.error(e as Error)
}
}
}