Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/commands/export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Flags} from '@oclif/core'

import HackMDCommand from '../command'
import {noteId} from '../flags'

export default class Export extends HackMDCommand {
static description = 'Export note content'

static examples = [
`$ hackmd-cli export --noteId=kNFWV5E-Qz-QP7u6XnNvyQ
# A note to be exported
`,
]

static flags = {
help: Flags.help({char: 'h'}),
noteId: noteId()
}

async run() {
const {flags} = await this.parse(Export)
const {noteId} = flags

if (!noteId) {
this.error('Flag noteId could not be empty')
}

try {
const APIClient = await this.getAPIClient()
const note = await APIClient.getNote(noteId)
this.log(note.content)
} catch (e) {
this.log('Export note content failed')
this.error(e as Error)
}
}
}