diff options
| author | typebrook <typebrook@gmail.com> | 2020-01-21 16:41:30 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-01-21 16:41:30 +0800 |
| commit | 00ca5c60f75b634ef058118b9638cca065d89cb4 (patch) | |
| tree | a465078ae99caef8695cdf07936302abd1536513 /scripts | |
| parent | 15b93348a5599a90ddcd533b4eeefac04a36e76c (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/gist | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/scripts/gist b/scripts/gist index 5fd5bbf..d14376e 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -48,7 +48,6 @@ | |||
| 48 | # * show this help message | 48 | # * show this help message |
| 49 | # gist (help | h) | 49 | # gist (help | h) |
| 50 | 50 | ||
| 51 | # TODO support auth prompt, remove personal info here | ||
| 52 | # TODO error handling, unit test | 51 | # TODO error handling, unit test |
| 53 | # TODO parallel branch works with json parsing on python | 52 | # TODO parallel branch works with json parsing on python |
| 54 | # TODO parallel branch works with wget and other stuff | 53 | # TODO parallel branch works with wget and other stuff |
| @@ -59,13 +58,13 @@ folder=~/git/gist | |||
| 59 | config=~/.config/gist | 58 | config=~/.config/gist |
| 60 | #------------------- | 59 | #------------------- |
| 61 | 60 | ||
| 62 | # while password is not true | 61 | # TODO error handling while password is not true |
| 63 | _auth() { | 62 | _auth() { |
| 64 | data="{\"scopes\":[\"gist\"], \"note\": \"gist-$(date -u +'%Y-%m-%dT%H:%M:%SZ')\"}" | 63 | data="{\"scopes\":[\"gist\"], \"note\": \"gist-$(date -u +'%Y-%m-%dT%H:%M:%SZ')\"}" |
| 65 | read -p "Github username: " user | 64 | read -p "Github username: " user |
| 66 | read -sp "Github password: " password | 65 | read -sp "Github password: " password |
| 67 | mkdir -p ~/.config | 66 | mkdir -p ~/.config |
| 68 | echo user=$user > $config | 67 | umask 0077 && echo user=$user > $config |
| 69 | 68 | ||
| 70 | curl -s https://api.github.com/authorizations \ | 69 | curl -s https://api.github.com/authorizations \ |
| 71 | --user "$user:$password" \ | 70 | --user "$user:$password" \ |
| @@ -79,7 +78,7 @@ _auth() { | |||
| 79 | sed 's/^/github_api_token=/' >> $config | 78 | sed 's/^/github_api_token=/' >> $config |
| 80 | } | 79 | } |
| 81 | 80 | ||
| 82 | while ! source $config || [[ -z "$user" ]]; do | 81 | while ! source $config 2> /dev/tty || [[ -z "$user" ]] || [[ -z "$github_api_token" ]]; do |
| 83 | _auth | 82 | _auth |
| 84 | done | 83 | done |
| 85 | 84 | ||
| @@ -301,8 +300,6 @@ case "$1" in | |||
| 301 | _clean_repos ;; | 300 | _clean_repos ;; |
| 302 | help | h) | 301 | help | h) |
| 303 | _help_message ;; | 302 | _help_message ;; |
| 304 | auth | a) | ||
| 305 | _auth ;; | ||
| 306 | *) | 303 | *) |
| 307 | _goto_gist "$1" ;; | 304 | _goto_gist "$1" ;; |
| 308 | esac | 305 | esac |