diff options
author | typebrook <typebrook@gmail.com> | 2019-12-30 16:18:34 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-30 16:18:34 +0800 |
commit | 07228d5f372d171618f28a64b446759e7eeadf4a (patch) | |
tree | 30c7cf69fa720fa8540742b2cb4e6ea9b60c78ff /scripts | |
parent | f791483cb24005b7d07f2ca9f2737490b3fdb2ab (diff) |
update
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gist | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/gist b/scripts/gist index 834d6cf..b55012b 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -110,15 +110,19 @@ _show_detail() { | |||
110 | # create a new gist with a file and description | 110 | # create a new gist with a file and description |
111 | # TODO support folder of files | 111 | # TODO support folder of files |
112 | _create_gist() { | 112 | _create_gist() { |
113 | FILE=$(basename $1) | 113 | echo -n 'description: ' |
114 | 114 | read DESC | |
115 | jq --arg FILE "$FILE" --arg DESC "$2" '. as $content | { | 115 | |
116 | public: true, | 116 | echo $@ | tr " " "\n" |\ |
117 | files: { | 117 | while read file; do |
118 | ($FILE): {content: $content} | 118 | FILE=$(basename $file) |
119 | }, | 119 | jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file |
120 | done |\ | ||
121 | jq -s --arg DESC "$DESC" '{ | ||
122 | public: true, | ||
123 | files: add, | ||
120 | description: ($DESC) | 124 | description: ($DESC) |
121 | }' -R -s $1 |\ | 125 | }' |\ |
122 | curl -s -H "$auth_header" --data @- $github_api/gists > /dev/null && \ | 126 | curl -s -H "$auth_header" --data @- $github_api/gists > /dev/null && \ |
123 | _update | 127 | _update |
124 | } | 128 | } |
@@ -137,7 +141,8 @@ case "$1" in | |||
137 | cat $index | 141 | cat $index |
138 | ;; | 142 | ;; |
139 | create | c) | 143 | create | c) |
140 | _create_gist "$2" "$3" | 144 | shift; |
145 | _create_gist $@ | ||
141 | ;; | 146 | ;; |
142 | edit | e) | 147 | edit | e) |
143 | _edit_gist "$2" "$3" | 148 | _edit_gist "$2" "$3" |