From 74752dce17c9cbbdc2d9f7db9cee640d86661c8b Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 22 Jan 2020 10:05:43 +0800 Subject: update --- scripts/gist | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 9654a49..2fc5624 100755 --- a/scripts/gist +++ b/scripts/gist @@ -52,11 +52,10 @@ # TODO parallel branch works with json parsing on python # TODO parallel branch works with wget and other stuff # TODO completion -# define your environmemnts here -#------------------- -folder=~/git/gist + +# Validate settings. config=~/.config/gistrc -#------------------- +[ "$TRACE" ] && set -x # TODO error handling while password is not true _auth() { @@ -83,13 +82,11 @@ done github_api=https://api.github.com auth_header="Authorization: token $github_api_token" +[[ -z $folder ]] && folder=~/git/gist mkdir -p $folder index=$folder/index starred=$folder/starred -# Validate settings. -[ "$TRACE" ] && set -x - # Show the list of gist, but not updated time # TODO show git status outdated _show_list() { @@ -275,14 +272,20 @@ _help_message() { sed -E -n ' /^$/ q; 8,$ s/^#//p' $0 } +# TODO consider the case that $2 is empty -> remove original setting _configure() { + [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null case "$1 $2" in - auto_sync[[:space:]]*) echo -n $1 ;;& - *true) echo =$2;; - *false) echo =$2;; - folder) echo -n $1=$2 ;; + token[[:space:]]????????????????????????????????????????) + echo $1=$2 ;; + auto_sync[[:space:]]true) echo $1=$2 ;; + auto_sync[[:space:]]false) echo $1=$2 ;; + folder[[:space:]]*) echo $1=$2 ;; + *) echo Not well formated && exit 0;; esac >> $config sed -i "$ q; /^$1=/ d" $config + + cat $config } case "$1" in -- cgit v1.2.3-70-g09d2