From f791483cb24005b7d07f2ca9f2737490b3fdb2ab Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 30 Dec 2019 15:12:29 +0800 Subject: update --- scripts/gist | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 9dfa31d..834d6cf 100755 --- a/scripts/gist +++ b/scripts/gist @@ -49,6 +49,9 @@ auth_header="Authorization: token $github_api_token" mkdir -p $folder index=$folder/index +# Validate settings. +[ "$TRACE" ] && set -x && echo foo + # get the list of gists _update() { curl -s -H "$auth_header" $github_api/users/$user/gists |\ -- cgit v1.2.3-70-g09d2 From 07228d5f372d171618f28a64b446759e7eeadf4a Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 30 Dec 2019 16:18:34 +0800 Subject: update --- scripts/gist | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 834d6cf..b55012b 100755 --- a/scripts/gist +++ b/scripts/gist @@ -110,15 +110,19 @@ _show_detail() { # create a new gist with a file and description # TODO support folder of files _create_gist() { - FILE=$(basename $1) - - jq --arg FILE "$FILE" --arg DESC "$2" '. as $content | { - public: true, - files: { - ($FILE): {content: $content} - }, + echo -n 'description: ' + read DESC + + echo $@ | tr " " "\n" |\ + while read file; do + FILE=$(basename $file) + jq --arg FILE "$FILE" '. as $content | { ($FILE): {content: $content} }' -Rs $file + done |\ + jq -s --arg DESC "$DESC" '{ + public: true, + files: add, description: ($DESC) - }' -R -s $1 |\ + }' |\ curl -s -H "$auth_header" --data @- $github_api/gists > /dev/null && \ _update } @@ -137,7 +141,8 @@ case "$1" in cat $index ;; create | c) - _create_gist "$2" "$3" + shift; + _create_gist $@ ;; edit | e) _edit_gist "$2" "$3" -- cgit v1.2.3-70-g09d2