diff options
| -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 |