diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gist | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/gist b/scripts/gist index 7da458d..40d723a 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -6,7 +6,7 @@ | |||
6 | # | 6 | # |
7 | # | 7 | # |
8 | # This script host your gists as local cloned git repo | 8 | # This script host your gists as local cloned git repo |
9 | # It works under GNU with jq and curl, both are easy to get in most cases | 9 | # It works under GNU curl, which is easy to get in most cases |
10 | # | 10 | # |
11 | # Use the following commands to manage your gists: | 11 | # Use the following commands to manage your gists: |
12 | # | 12 | # |
@@ -255,6 +255,18 @@ for file in raw["files"].keys(): | |||
255 | ' | 255 | ' |
256 | } | 256 | } |
257 | 257 | ||
258 | # equal to jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' | ||
259 | _handle_comment() { | ||
260 | echo ' | ||
261 | for comment in raw: | ||
262 | print() | ||
263 | print("|", "user:", comment["user"]["login"]) | ||
264 | print("|", "created_at:", comment["created_at"]) | ||
265 | print("|", "updated_at:", comment["updated_at"]) | ||
266 | print("|", comment["body"]) | ||
267 | ' | ||
268 | } | ||
269 | |||
258 | # TODO format with simple text | 270 | # TODO format with simple text |
259 | _show_detail() { | 271 | _show_detail() { |
260 | _gist_id $1 | 272 | _gist_id $1 |
@@ -262,7 +274,7 @@ _show_detail() { | |||
262 | | AccessJsonElement "$(_handle_gist)" | 274 | | AccessJsonElement "$(_handle_gist)" |
263 | 275 | ||
264 | curl -s $github_api/gists/$GIST_ID/comments \ | 276 | curl -s $github_api/gists/$GIST_ID/comments \ |
265 | | jq '.[] | {user: .user.login, created_at: .created_at, updated_at: .updated_at, body: .body}' | 277 | | AccessJsonElement "$(_handle_comment)" |
266 | } | 278 | } |
267 | 279 | ||
268 | # FIXME put file before parameters | 280 | # FIXME put file before parameters |