Skip to content

Commit 1998d8a

Browse files
committed
feat: extend note and folder CLI capabilities
1 parent 12d28d2 commit 1998d8a

18 files changed

Lines changed: 436 additions & 52 deletions

File tree

‎README.md‎

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ USAGE
4242

4343
## Full API access
4444

45-
The existing `notes`, `folders`, and other commands remain unchanged. For operations without a dedicated command, use the installed API client's generated operations:
45+
Use the focused `notes`, `folders`, and other commands for common workflows. For operations without a dedicated command, use the installed API client's generated operations:
4646

4747
```bash
4848
hackmd-cli api operations
@@ -379,23 +379,28 @@ Update folder
379379

380380
```
381381
USAGE
382-
$ hackmd-cli folders update [--color <value>] [--description <value>] [--folderId <value>] [-h] [--icon <value>]
383-
[--name <value>] [--parentFolderId <value>]
382+
$ hackmd-cli folders update [--clear description|icon|color] [--color <value>] [--description <value>] [--folderId
383+
<value>] [-h] [--icon <value>] [--name <value>] [--parentFolderId <value>] [--root]
384384
385385
FLAGS
386386
-h, --help Show CLI help.
387+
--clear=<option>... clear fields: description, icon, color (repeatable)
388+
<options: description|icon|color>
387389
--color=<value> folder color
388390
--description=<value> folder description
389391
--folderId=<value> HackMD folder id
390392
--icon=<value> folder icon
391393
--name=<value> folder name
392394
--parentFolderId=<value> parent folder id
395+
--root move to the root folder
393396
394397
DESCRIPTION
395398
Update folder
396399
397400
EXAMPLES
398401
$ hackmd-cli folders update --folderId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d --name='docs' --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c --description='Docs' --icon=1F600 --color=#4F46E5
402+
403+
$ hackmd-cli folders update --folderId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d --root --clear=description
399404
```
400405

401406
## `hackmd-cli help [COMMANDS]`
@@ -424,15 +429,16 @@ List user browse history
424429

425430
```
426431
USAGE
427-
$ hackmd-cli history [-h] [--columns <value> | -x] [--sort <value>] [--filter <value>] [--output
428-
csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
432+
$ hackmd-cli history [-h] [--limit <value>] [--columns <value> | -x] [--sort <value>] [--filter <value>]
433+
[--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
429434
430435
FLAGS
431436
-h, --help Show CLI help.
432437
-x, --extended show extra columns
433438
--columns=<value> only show provided columns (comma-separated)
434439
--csv output is csv format [alias: --output=csv]
435440
--filter=<value> filter property by partial string matching, ex: name=foo
441+
--limit=<value> maximum number of history items to return
436442
--no-header hide table header from output
437443
--no-truncate do not truncate output to fit screen
438444
--output=<option> output in a more machine friendly format
@@ -448,6 +454,8 @@ EXAMPLES
448454
────────────────────── ──────────────────────────────── ────────────────────── ────────
449455
raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q null
450456
BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test
457+
458+
$ hackmd-cli history --limit=10
451459
```
452460

453461
_See code: [src/commands/history.ts](https://github.com/hackmdio/hackmd-cli/blob/v2.5.1/src/commands/history.ts)_
@@ -535,9 +543,10 @@ Create a note
535543

536544
```
537545
USAGE
538-
$ hackmd-cli notes create [--commentPermission <value>] [--content <value>] [-e] [-h] [--parentFolderId <value>]
539-
[--readPermission <value>] [--tags <value>] [--title <value>] [--writePermission <value>] [--columns <value> | -x]
540-
[--sort <value>] [--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
546+
$ hackmd-cli notes create [--commentPermission <value>] [--content <value>] [--description <value>] [-e] [-h]
547+
[--parentFolderId <value>] [--readPermission <value>] [--tags <value>] [--title <value>] [--writePermission <value>]
548+
[--columns <value> | -x] [--sort <value>] [--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]]
549+
[--no-header | ]
541550
542551
FLAGS
543552
-e, --editor create note with $EDITOR
@@ -547,6 +556,7 @@ FLAGS
547556
--commentPermission=<value> set comment permission: disabled, forbidden, owners, signed_in_users, everyone
548557
--content=<value> new note content
549558
--csv output is csv format [alias: --output=csv]
559+
--description=<value> note description
550560
--filter=<value> filter property by partial string matching, ex: name=foo
551561
--no-header hide table header from output
552562
--no-truncate do not truncate output to fit screen
@@ -576,6 +586,8 @@ EXAMPLES
576586
Or you can pipe content via Unix pipeline:
577587
578588
cat README.md | hackmd-cli notes create
589+
590+
$ hackmd-cli notes create --title='My note' --description='Short summary'
579591
```
580592

581593
## `hackmd-cli notes delete`
@@ -603,16 +615,21 @@ Update note
603615

604616
```
605617
USAGE
606-
$ hackmd-cli notes update [--content <value>] [-h] [--noteId <value>] [--parentFolderId <value>] [--permalink
607-
<value>] [--readPermission <value>] [--tags <value>] [--title <value>] [--writePermission <value>]
618+
$ hackmd-cli notes update [--clear description] [--content <value>] [--description <value>] [-h] [--noteId
619+
<value>] [--parentFolderId <value>] [--permalink <value>] [--readPermission <value>] [--root] [--tags <value>]
620+
[--title <value>] [--writePermission <value>]
608621
609622
FLAGS
610623
-h, --help Show CLI help.
624+
--clear=<option>... clear fields: description (repeatable)
625+
<options: description>
611626
--content=<value> new note content
627+
--description=<value> note description
612628
--noteId=<value> HackMD note id
613629
--parentFolderId=<value> parent folder id
614630
--permalink=<value> note permalink
615631
--readPermission=<value> set note permission: owner, signed_in, guest
632+
--root move to the root folder
616633
--tags=<value> set note tags, comma-separated (e.g. tag1,tag2)
617634
--title=<value> new note title
618635
--writePermission=<value> set note permission: owner, signed_in, guest
@@ -632,6 +649,10 @@ EXAMPLES
632649
$ hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --tags=tag1,tag2
633650
634651
$ cat README.md | hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA
652+
653+
$ hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --description='Updated summary' --root
654+
655+
$ hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --clear=description
635656
```
636657

637658
## `hackmd-cli team-folders`
@@ -755,24 +776,29 @@ Update team folder
755776

756777
```
757778
USAGE
758-
$ hackmd-cli team-folders update [--color <value>] [--description <value>] [--folderId <value>] [-h] [--icon <value>]
759-
[--name <value>] [--parentFolderId <value>] [--teamPath <value>]
779+
$ hackmd-cli team-folders update [--clear description|icon|color] [--color <value>] [--description <value>] [--folderId
780+
<value>] [-h] [--icon <value>] [--name <value>] [--parentFolderId <value>] [--root] [--teamPath <value>]
760781
761782
FLAGS
762783
-h, --help Show CLI help.
784+
--clear=<option>... clear fields: description, icon, color (repeatable)
785+
<options: description|icon|color>
763786
--color=<value> folder color
764787
--description=<value> folder description
765788
--folderId=<value> HackMD folder id
766789
--icon=<value> folder icon
767790
--name=<value> folder name
768791
--parentFolderId=<value> parent folder id
792+
--root move to the root folder
769793
--teamPath=<value> HackMD team path
770794
771795
DESCRIPTION
772796
Update team folder
773797
774798
EXAMPLES
775799
$ hackmd-cli team-folders update --teamPath=CLI-test --folderId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d --name='team-docs' --parentFolderId=fc7a3d48-4a07-4cbf-bf4f-e65dd896e01c --description='Docs' --icon=1F600 --color=#4F46E5
800+
801+
$ hackmd-cli team-folders update --teamPath=CLI-test --folderId=a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d --root --clear=description
776802
```
777803

778804
## `hackmd-cli team-notes`
@@ -781,8 +807,8 @@ HackMD team-notes commands
781807

782808
```
783809
USAGE
784-
$ hackmd-cli team-notes [-h] [--teamPath <value>] [--columns <value> | -x] [--sort <value>] [--filter <value>]
785-
[--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
810+
$ hackmd-cli team-notes [-h] [--noteId <value>] [--teamPath <value>] [--columns <value> | -x] [--sort <value>]
811+
[--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
786812
787813
FLAGS
788814
-h, --help Show CLI help.
@@ -792,6 +818,7 @@ FLAGS
792818
--filter=<value> filter property by partial string matching, ex: name=foo
793819
--no-header hide table header from output
794820
--no-truncate do not truncate output to fit screen
821+
--noteId=<value> HackMD note id
795822
--output=<option> output in a more machine friendly format
796823
<options: csv|json|yaml>
797824
--sort=<value> property to sort by (prepend '-' for descending)
@@ -806,6 +833,8 @@ EXAMPLES
806833
────────────────────── ──────────────────────────────── ──────── ────────
807834
WNkLM6gkS0Cg2cQ8rv7bYA a team note null CLI-test
808835
BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null CLI-test
836+
837+
$ hackmd-cli team-notes --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA
809838
```
810839

811840
_See code: [src/commands/team-notes/index.ts](https://github.com/hackmdio/hackmd-cli/blob/v2.5.1/src/commands/team-notes/index.ts)_
@@ -816,10 +845,10 @@ Create a team note
816845

817846
```
818847
USAGE
819-
$ hackmd-cli team-notes create [--commentPermission <value>] [--content <value>] [-e] [-h] [--parentFolderId <value>]
820-
[--readPermission <value>] [--tags <value>] [--teamPath <value>] [--title <value>] [--writePermission <value>]
821-
[--columns <value> | -x] [--sort <value>] [--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]]
822-
[--no-header | ]
848+
$ hackmd-cli team-notes create [--commentPermission <value>] [--content <value>] [--description <value>] [-e] [-h]
849+
[--parentFolderId <value>] [--readPermission <value>] [--tags <value>] [--teamPath <value>] [--title <value>]
850+
[--writePermission <value>] [--columns <value> | -x] [--sort <value>] [--filter <value>] [--output csv|json|yaml |
851+
| [--csv | --no-truncate]] [--no-header | ]
823852
824853
FLAGS
825854
-e, --editor create note with $EDITOR
@@ -829,6 +858,7 @@ FLAGS
829858
--commentPermission=<value> set comment permission: disabled, forbidden, owners, signed_in_users, everyone
830859
--content=<value> new note content
831860
--csv output is csv format [alias: --output=csv]
861+
--description=<value> note description
832862
--filter=<value> filter property by partial string matching, ex: name=foo
833863
--no-header hide table header from output
834864
--no-truncate do not truncate output to fit screen
@@ -859,6 +889,8 @@ EXAMPLES
859889
Or you can pipe content via Unix pipeline:
860890
861891
cat README.md | hackmd-cli team-notes create --teamPath=CLI-test
892+
893+
$ hackmd-cli team-notes create --teamPath=CLI-test --title='My note' --description='Short summary'
862894
```
863895

864896
## `hackmd-cli team-notes delete`
@@ -887,17 +919,21 @@ Update team note
887919

888920
```
889921
USAGE
890-
$ hackmd-cli team-notes update [--content <value>] [-h] [--noteId <value>] [--parentFolderId <value>] [--permalink
891-
<value>] [--readPermission <value>] [--tags <value>] [--teamPath <value>] [--title <value>] [--writePermission
892-
<value>]
922+
$ hackmd-cli team-notes update [--clear description] [--content <value>] [--description <value>] [-h] [--noteId
923+
<value>] [--parentFolderId <value>] [--permalink <value>] [--readPermission <value>] [--root] [--tags <value>]
924+
[--teamPath <value>] [--title <value>] [--writePermission <value>]
893925
894926
FLAGS
895927
-h, --help Show CLI help.
928+
--clear=<option>... clear fields: description (repeatable)
929+
<options: description>
896930
--content=<value> new note content
931+
--description=<value> note description
897932
--noteId=<value> HackMD note id
898933
--parentFolderId=<value> parent folder id
899934
--permalink=<value> note permalink
900935
--readPermission=<value> set note permission: owner, signed_in, guest
936+
--root move to the root folder
901937
--tags=<value> set note tags, comma-separated (e.g. tag1,tag2)
902938
--teamPath=<value> HackMD team path
903939
--title=<value> new note title
@@ -918,6 +954,10 @@ EXAMPLES
918954
$ hackmd-cli team-notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --tags=tag1,tag2
919955
920956
$ cat README.md | hackmd-cli team-notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA
957+
958+
$ hackmd-cli team-notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --description='Updated summary' --root
959+
960+
$ hackmd-cli team-notes update --teamPath=CLI-test --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --clear=description
921961
```
922962

923963
## `hackmd-cli teams`

‎hackmd-cli.skill‎

254 Bytes
Binary file not shown.

‎hackmd-cli/SKILL.md‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ hackmd-cli notes
6767
hackmd-cli notes --noteId=<id>
6868

6969
# Create note
70-
hackmd-cli notes create --content='# Title' --title='My Note'
70+
hackmd-cli notes create --content='# Title' --title='My Note' --description='Summary'
7171
hackmd-cli notes create --readPermission=owner --writePermission=owner
7272

7373
# Create note inside a folder
@@ -82,9 +82,12 @@ hackmd-cli notes create -e
8282
# Update note
8383
hackmd-cli notes update --noteId=<id> --content='# New Content'
8484
hackmd-cli notes update --noteId=<id> --title='New title'
85+
hackmd-cli notes update --noteId=<id> --description='New summary'
86+
hackmd-cli notes update --noteId=<id> --clear=description
8587

8688
# Move note into a folder
8789
hackmd-cli notes update --noteId=<id> --parentFolderId=<folder-id>
90+
hackmd-cli notes update --noteId=<id> --root
8891

8992
# Delete note
9093
hackmd-cli notes delete --noteId=<id>
@@ -96,18 +99,24 @@ hackmd-cli notes delete --noteId=<id>
9699
# List team notes
97100
hackmd-cli team-notes --teamPath=<team-path>
98101

102+
# Get a specific team note
103+
hackmd-cli team-notes --teamPath=<team-path> --noteId=<id>
104+
99105
# Create team note
100-
hackmd-cli team-notes create --teamPath=<team-path> --content='# Team Doc'
106+
hackmd-cli team-notes create --teamPath=<team-path> --content='# Team Doc' --description='Summary'
101107

102108
# Create team note inside a folder
103109
hackmd-cli team-notes create --teamPath=<team-path> --parentFolderId=<folder-id> --content='# Team Doc'
104110

105111
# Update team note
106112
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --content='# Updated'
107113
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --title='New title'
114+
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --description='New summary'
115+
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --clear=description
108116

109117
# Move team note into a folder
110118
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --parentFolderId=<folder-id>
119+
hackmd-cli team-notes update --teamPath=<team-path> --noteId=<id> --root
111120

112121
# Delete team note
113122
hackmd-cli team-notes delete --teamPath=<team-path> --noteId=<id>
@@ -133,6 +142,8 @@ hackmd-cli folders create --name='Docs' --description='Project docs' --icon=1F60
133142

134143
# Update folder
135144
hackmd-cli folders update --folderId=<id> --name='Updated Docs'
145+
hackmd-cli folders update --folderId=<id> --root
146+
hackmd-cli folders update --folderId=<id> --clear=description --clear=icon --clear=color
136147

137148
# Delete folder
138149
hackmd-cli folders delete --folderId=<id>
@@ -162,6 +173,8 @@ hackmd-cli team-folders create --teamPath=<team-path> --name='Team Docs' --descr
162173

163174
# Update team folder
164175
hackmd-cli team-folders update --teamPath=<team-path> --folderId=<id> --name='Updated Team Docs'
176+
hackmd-cli team-folders update --teamPath=<team-path> --folderId=<id> --root
177+
hackmd-cli team-folders update --teamPath=<team-path> --folderId=<id> --clear=description
165178

166179
# Delete team folder
167180
hackmd-cli team-folders delete --teamPath=<team-path> --folderId=<id>
@@ -176,6 +189,7 @@ hackmd-cli team-folders order --teamPath=<team-path> --order='{"root":["folder-i
176189
```bash
177190
hackmd-cli teams # List accessible teams
178191
hackmd-cli history # List browsing history
192+
hackmd-cli history --limit=10 # Limit the number of items
179193
```
180194

181195
### Export
@@ -194,10 +208,15 @@ Available permission values:
194208
| `--writePermission` | `owner`, `signed_in`, `guest` |
195209
| `--commentPermission` | `disabled`, `forbidden`, `owners`, `signed_in_users`, `everyone` |
196210

197-
## Folder Flags
211+
## Note and Folder Update Flags
212+
213+
Omitted fields stay unchanged. `--description=''` sets an empty string; `--clear=description` removes the description. Do not set and clear the same field in one command.
198214

199215
```bash
200216
--parentFolderId=<folder-id> # Put note/folder inside another folder
217+
--root # Move a note/folder to root (update only)
218+
--clear=description # Clear note/folder description (update only)
219+
--clear=icon --clear=color # Clear folder fields (repeatable, update only)
201220
--icon=1F600 # Emoji unified codepoint string
202221
--color='#4F46E5' # Hex color string
203222
--order='{"root":["id1","id2"]}' # Folder ordering JSON

0 commit comments

Comments
 (0)