@@ -2,22 +2,22 @@ import {
22 CommentPermissionType ,
33 CreateNoteOptions ,
44 NotePermissionRole ,
5- } from " @hackmd/api/dist/type" ;
6- import { CliUx , Flags } from " @oclif/core" ;
7- import * as fs from "fs" ;
5+ } from ' @hackmd/api/dist/type'
6+ import { CliUx , Flags } from ' @oclif/core'
7+ import * as fs from 'fs'
88
9- import HackMDCommand from " ../../command" ;
9+ import HackMDCommand from ' ../../command'
1010import {
1111 commentPermission ,
1212 noteContent ,
1313 notePermission ,
1414 noteTitle ,
15- } from " ../../flags" ;
16- import { safeStdinRead , temporaryMD } from " ../../utils" ;
17- import openEditor from " ../../openEditor" ;
15+ } from ' ../../flags'
16+ import openEditor from ' ../../open-editor'
17+ import { safeStdinRead , temporaryMD } from ' ../../utils'
1818
1919export default class CreateCommand extends HackMDCommand {
20- static description = " Create a note" ;
20+ static description = ' Create a note'
2121
2222 static examples = [
2323 "notes create --content='# A new note' --readPermission=owner --writePermission=owner --commentPermission=disabled" ,
@@ -26,73 +26,73 @@ export default class CreateCommand extends HackMDCommand {
2626────────────────────── ──────────────────────────────── ────────────────────── ────────
2727raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q null` ,
2828
29- " Or you can pipe content via Unix pipeline:" ,
30- " cat README.md | hackmd-cli notes create" ,
31- ] ;
29+ ' Or you can pipe content via Unix pipeline:' ,
30+ ' cat README.md | hackmd-cli notes create' ,
31+ ]
3232
3333 static flags = {
34- help : Flags . help ( { char : "h" } ) ,
34+ help : Flags . help ( { char : 'h' } ) ,
3535 title : noteTitle ( ) ,
3636 content : noteContent ( ) ,
3737 readPermission : notePermission ( ) ,
3838 writePermission : notePermission ( ) ,
3939 commentPermission : commentPermission ( ) ,
4040 editor : Flags . boolean ( {
41- char : "e" ,
42- description : " create note with $EDITOR" ,
41+ char : 'e' ,
42+ description : ' create note with $EDITOR' ,
4343 } ) ,
4444 ...CliUx . ux . table . flags ( ) ,
45- } ;
45+ }
4646
4747 async run ( ) {
48- const { flags } = await this . parse ( CreateCommand ) ;
49- const pipeString = safeStdinRead ( ) ;
48+ const { flags} = await this . parse ( CreateCommand )
49+ const pipeString = safeStdinRead ( )
5050
5151 const options : CreateNoteOptions = {
5252 title : flags . title ,
5353 content : pipeString || flags . content ,
5454 readPermission : flags . readPermission as NotePermissionRole ,
5555 writePermission : flags . writePermission as NotePermissionRole ,
5656 commentPermission : flags . commentPermission as CommentPermissionType ,
57- } ;
57+ }
5858
5959 if ( flags . editor ) {
6060 try {
61- const mdFile = temporaryMD ( ) ;
62- await openEditor ( mdFile ) ;
61+ const mdFile = temporaryMD ( )
62+ await openEditor ( mdFile )
6363
64- options . content = fs . readFileSync ( mdFile ) . toString ( ) ;
64+ options . content = fs . readFileSync ( mdFile ) . toString ( )
6565 } catch ( e ) {
66- this . error ( e as Error ) ;
66+ this . error ( e as Error )
6767 }
6868 }
6969
7070 try {
71- const APIClient = await this . getAPIClient ( ) ;
72- const note = await APIClient . createNote ( options ) ;
71+ const APIClient = await this . getAPIClient ( )
72+ const note = await APIClient . createNote ( options )
7373
7474 CliUx . ux . table (
7575 [ note ] ,
7676 {
7777 id : {
78- header : "ID" ,
78+ header : 'ID' ,
7979 } ,
8080 title : { } ,
8181 userPath : {
82- header : " User path" ,
82+ header : ' User path' ,
8383 } ,
8484 teamPath : {
85- header : " Team path" ,
85+ header : ' Team path' ,
8686 } ,
8787 } ,
8888 {
8989 printLine : this . log . bind ( this ) ,
9090 ...flags ,
9191 }
92- ) ;
92+ )
9393 } catch ( e ) {
94- this . log ( " Create note failed" ) ;
95- this . error ( e as Error ) ;
94+ this . log ( ' Create note failed' )
95+ this . error ( e as Error )
9696 }
9797 }
9898}
0 commit comments