From 2641733128bfe65dae4ec46a46856ee8109899c0 Mon Sep 17 00:00:00 2001 From: Jon-William Lewis Date: Fri, 26 Aug 2016 14:52:45 -0500 Subject: [PATCH] Enhanced version control init --- src/bash-completion.src.sh | 6 ++++-- src/libSNS.src.sh | 6 ++++++ src/libStore.src.sh | 9 ++++++++- src/sns.src.sh | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/bash-completion.src.sh b/src/bash-completion.src.sh index bee1f8c..f7d0cc9 100644 --- a/src/bash-completion.src.sh +++ b/src/bash-completion.src.sh @@ -15,6 +15,8 @@ # Brian Mattern . All Rights Reserved. # This file is licensed under the GPLv2+. Please see COPYING for more information. +if [ -r "$HOME"/.local/sns/sns.conf ]; then source "$HOME"/.local/sns/sns.conf; fi + _sns_complete_entries () { prefix="${SNS_STORE_DIR:-$HOME/.local/sns/notes/}" suffix=".note" @@ -66,7 +68,7 @@ _sns_complete_folders () { _sns_complete_keys () { local IFS=$'\n' # Extract names and email addresses from gpg --list-keys - local keys="$(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')" + local keys="$(gpg2 --list-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')" COMPREPLY+=($(compgen -W "${keys}" -- ${cur})) } @@ -75,7 +77,7 @@ _sns() COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" local commands="--create --config --delete --edit --help --print --list --init\ - -c -d -e -h -p -l -i" + -c "$VCTL" -d -e -h -p -l -i" if [[ $COMP_CWORD -gt 1 ]]; then local lastarg="${COMP_WORDS[$COMP_CWORD-1]}" case "${COMP_WORDS[1]}" in diff --git a/src/libSNS.src.sh b/src/libSNS.src.sh index af47ac9..9b8b531 100644 --- a/src/libSNS.src.sh +++ b/src/libSNS.src.sh @@ -117,6 +117,12 @@ if [ "$ENCRYPTION" == "TRUE" ]; then fi fi +# If $VCTL is defined, add the edited note to the repo. +if [ "$VCTL" ]; then + >&2 printf "%s %s %s\n" "- adding to" "$VCTL" "repo". + verctl "$VCTL" add ""$NOTES_DIR"/$NOTE" + verctl "$VCTL" commit -m "Added/Changed $NOTE" > /dev/null +fi } function help { printf "\n%s" "usage: sns [-cedlp] " diff --git a/src/libStore.src.sh b/src/libStore.src.sh index 4b1c934..4fe89ff 100644 --- a/src/libStore.src.sh +++ b/src/libStore.src.sh @@ -54,7 +54,7 @@ else fi if [ "$WILL_INIT" == "TRUE" ]; then - printf "%s\n" "- Environment initialized in $ROOT_DIR" + printf "%s\n" "- Store initialized in $ROOT_DIR" else printf "%s\n" "- Store already initialized." fi @@ -70,3 +70,10 @@ function verify_store { fi done } +function verctl { + "$@" + if [ $2 == "init" ]; then + "$VCTL" add . + "$VCTL" commit -m "Initial Commit" + fi +} diff --git a/src/sns.src.sh b/src/sns.src.sh index ca25794..3f83306 100644 --- a/src/sns.src.sh +++ b/src/sns.src.sh @@ -145,7 +145,7 @@ else ;; "$VCTL") cd "$ROOT_DIR" - "${@:$INDEX}" + verctl "${@:$INDEX}" exit 0 ;; *)