Skip to content

Commit 5d0b4fb

Browse files
committed
Implement JSON output for history
1 parent 2f12115 commit 5d0b4fb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bin/codimd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Commands:
6363
profile
6464
View the current authenticated user details.
6565
66-
history
66+
history [--json]
6767
View the current logged in user's list of accessed notes.
6868
6969
Config:
@@ -350,7 +350,7 @@ function user_history() {
350350
--silent \
351351
--cookie "$CODIMD_COOKIES_FILE" \
352352
"${CODIMD_SERVER}/history" \
353-
| jq -r '["ID", "", "", "Name"], (.history[] | [.id, .text]) | @tsv'
353+
| ([[ ${1:-} = --json ]] && cat || jq -r '["ID", "", "", "Name"], (.history[] | [.id, .text]) | @tsv')
354354
}
355355

356356
function delete_note() {
@@ -399,7 +399,7 @@ function main() {
399399
user_profile
400400
;;
401401
history)
402-
user_history
402+
user_history "${1:-}"
403403
;;
404404
*)
405405
echo "Error: unrecognized command '$subcommand'." >&2

0 commit comments

Comments
 (0)