diff options
author | typebrook <typebrook@gmail.com> | 2019-12-24 17:50:42 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-24 17:50:42 +0800 |
commit | 64e62e83d42a56dc4088663ab0454f234dead8fe (patch) | |
tree | 29721d13ad6a2d1511265c80a333b619ef36d2f7 | |
parent | 823d8c6199c418101fdf3f2b58bd1fb3b13eb349 (diff) |
update
-rwxr-xr-x | scripts/gist | 26 |
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 | |||
54 | fi | 60 | fi |
55 | 61 | ||
56 | case "$1" in | 62 | case "$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 | ;; |
76 | esac | 78 | esac |