From 868fb26ab6355361104354c9e8a04f3b2b91c056 Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 29 Jan 2020 11:31:50 +0800 Subject: update --- scripts/gist | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 7da458d..40d723a 100755 --- a/scripts/gist +++ b/scripts/gist @@ -6,7 +6,7 @@ # # # This script host your gists as local cloned git repo -# It works under GNU with jq and curl, both are easy to get in most cases +# It works under GNU curl, which is easy to get in most cases # # Use the following commands to manage your gists: # @@ -255,6 +255,18 @@ for file in raw["files"].keys(): ' } +# equal to jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' +_handle_comment() { + echo ' +for comment in raw: + print() + print("|", "user:", comment["user"]["login"]) + print("|", "created_at:", comment["created_at"]) + print("|", "updated_at:", comment["updated_at"]) + print("|", comment["body"]) + ' +} + # TODO format with simple text _show_detail() { _gist_id $1 @@ -262,7 +274,7 @@ _show_detail() { | AccessJsonElement "$(_handle_gist)" curl -s $github_api/gists/$GIST_ID/comments \ - | jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' + | AccessJsonElement "$(_handle_comment)" } # FIXME put file before parameters -- cgit v1.2.3-70-g09d2