summaryrefslogtreecommitdiffhomepage
path: root/scripts/gist
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-24 17:50:42 +0800
committertypebrook <typebrook@gmail.com>2019-12-24 17:50:42 +0800
commit64e62e83d42a56dc4088663ab0454f234dead8fe (patch)
tree29721d13ad6a2d1511265c80a333b619ef36d2f7 /scripts/gist
parent823d8c6199c418101fdf3f2b58bd1fb3b13eb349 (diff)
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-xscripts/gist26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/gist b/scripts/gist
index 48acd44..f815e3e 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -39,11 +39,17 @@ _show_detail() {
39 curl -s -H "Authorization: token $github_api_token" https://api.github.com/gists/$GIST_ID 39 curl -s -H "Authorization: token $github_api_token" https://api.github.com/gists/$GIST_ID
40} 40}
41 41
42# FIXME cannot upload a file
43_create() { 42_create() {
44 jq '. as $file | {public: true, files: {content: $file}, description: "no desc"}' -R -s $1 |\ 43 FILE=$(basename $1)
45 tee /dev/tty |\ 44
46 curl -v -H "Authorization: token $github_api_token" \ 45 jq --arg FILE "$FILE" --arg DESC ""$2"" '. as $content | {
46 public: true,
47 files: {
48 ($FILE): {content: $content}
49 },
50 description: ($DESC)
51 }' -R -s $1 |\
52 curl -s -H "Authorization: token $github_api_token" \
47 --data @- \ 53 --data @- \
48 https://api.github.com/gists 54 https://api.github.com/gists
49} 55}
@@ -54,23 +60,19 @@ if [[ $# -eq 0 ]]; then
54fi 60fi
55 61
56case "$1" in 62case "$1" in
63 create | c)
64 _create $2 $3
65 ;;
57 update | u) 66 update | u)
58 _update 67 _update
59 ;; 68 ;;
60
61 detail | d) 69 detail | d)
62 _show_detail $2 70 _show_detail $2
63 ;; 71 ;;
64
65 delete | D) 72 delete | D)
66 _delete_gist $2 73 _delete_gist $2
67 ;; 74 ;;
68
69 create | c)
70 _create $2
71 ;;
72
73 *) 75 *)
74 _go_to_gist $1 76 _go_to_gist $2
75 ;; 77 ;;
76esac 78esac