diff options
author | typebrook <typebrook@gmail.com> | 2019-12-24 17:05:56 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-24 17:05:56 +0800 |
commit | 823d8c6199c418101fdf3f2b58bd1fb3b13eb349 (patch) | |
tree | 32b884fcd9a318253f42128e8d96e16ece33809e /scripts/gist | |
parent | d6be8f8ec764229583f2e99fb36f334435453419 (diff) |
update
Diffstat (limited to 'scripts/gist')
-rwxr-xr-x | scripts/gist | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/scripts/gist b/scripts/gist index ffc479f..48acd44 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -41,22 +41,13 @@ _show_detail() { | |||
41 | 41 | ||
42 | # FIXME cannot upload a file | 42 | # FIXME cannot upload a file |
43 | _create() { | 43 | _create() { |
44 | jq '. as $file | {public: true, files: {content: $file}, description: "no desc"}' -R -s $1 |\ | ||
45 | tee /dev/tty |\ | ||
44 | curl -v -H "Authorization: token $github_api_token" \ | 46 | curl -v -H "Authorization: token $github_api_token" \ |
45 | --data "$(generate_post_data $1 | tee json)" \ | 47 | --data @- \ |
46 | https://api.github.com/gists | 48 | https://api.github.com/gists |
47 | } | 49 | } |
48 | 50 | ||
49 | generate_post_data() { | ||
50 | cat <<EOF | ||
51 | { | ||
52 | "public": true, | ||
53 | "files": { "$1": {"content": "$(cat $1 | sed 's/"/\\\"/g' | tr '\n' ',')"}}, | ||
54 | "description": $2 | ||
55 | } | ||
56 | EOF | ||
57 | } | ||
58 | |||
59 | |||
60 | if [[ $# -eq 0 ]]; then | 51 | if [[ $# -eq 0 ]]; then |
61 | cat $index | 52 | cat $index |
62 | exit 0 | 53 | exit 0 |