Code cleanup
This commit is contained in:
@@ -13,6 +13,6 @@ function help {
|
||||
echo " -h | --help : Display this message"
|
||||
echo " -p | --print : Print note to console"
|
||||
echo " -l | --list : List all notes in NOTEBOOK"
|
||||
echo " -w | --wconf : Rewrite default configuration"
|
||||
echo " -i | --init : Write default config and initalize SNS store"
|
||||
echo ""
|
||||
}
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
function init_store {
|
||||
|
||||
if [ ! -r "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; WILL_INIT="TRUE"; fi
|
||||
if [ ! -d "$ROOT_DIR" ]; then mkdir -p "$ROOT_DIR"; WILL_INIT="TRUE"; fi
|
||||
if [ ! -d "$TMP_DIR" ]; then mkdir -p "$TMP_DIR" ; WILL_INIT="TRUE"; fi
|
||||
|
||||
|
||||
cat > "$CONFIG_FILE" << EOF
|
||||
#==========================================================
|
||||
# Simple Note System Config, v2.0a8
|
||||
# Copyright 2014, Xenese Labs/Sicron-Perion XNF
|
||||
#==========================================================
|
||||
# This file contains directives for the Simple Note System.
|
||||
|
||||
#File extension to use (for listing notes)
|
||||
EXT=note
|
||||
EXT=note # File extension to use (for listing notes)
|
||||
|
||||
#Preferred Editor
|
||||
if [ -z "$EDITOR" ]; then
|
||||
EDITOR=vim
|
||||
fi
|
||||
#EDITOR= # Preferred Editor:
|
||||
# If you would like to specify a different editor for
|
||||
# sns to use, you may do so here.
|
||||
|
||||
#Encryption
|
||||
#WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST
|
||||
ENCRYPTION="FALSE" # Main Encryption Toggle:
|
||||
# WARNING: ANY PREVIOUSLY UNENCRYPTED NOTES WILL BE LOST
|
||||
# Change this to TRUE to enable encryption.
|
||||
|
||||
#ENCRYPTION="TRUE"
|
||||
ENCRYPTION="FALSE"
|
||||
|
||||
PUBKEY=""
|
||||
PUBKEY="" # Public Key
|
||||
# Encryption is done using GPG. You must enter your
|
||||
# public key's identifier here.
|
||||
EOF
|
||||
|
||||
chmod 600 "$CONFIG_FILE"
|
||||
|
||||
printf " - %s\n" "Rewrote Default Configuration"
|
||||
|
||||
if [ "$WILL_INIT" == "TRUE" ]; then
|
||||
printf "%s %s\n" "Environment initialized in" "$ROOT_DIR"
|
||||
printf " - %s %s\n" "Environment initialized in" "$ROOT_DIR"
|
||||
else
|
||||
printf "%s\n" "Environment already initialized."
|
||||
printf " - %s\n" "Store already initialized."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
function verify_store {
|
||||
STORE_DIRS=("$ROOT_DIR" "$NOTES_DIR" "$TMP_DIR")
|
||||
for DIR in ${STORE_DIRS[]}; do
|
||||
mkdir -p "$DIR"
|
||||
done
|
||||
}
|
||||
7
src/includes/verify_store.sns.sh
Normal file
7
src/includes/verify_store.sns.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
function verify_store {
|
||||
ETC_DIR="$(dirname \"$CONFIG_FILE\")"
|
||||
STORE_DIRS=("$ROOT_DIR" "$NOTES_DIR" "$TMP_DIR" "$ETC_DIR")
|
||||
for DIR in ${STORE_DIRS[@]}; do
|
||||
mkdir -p "$DIR"
|
||||
done
|
||||
}
|
||||
@@ -8,14 +8,14 @@
|
||||
else
|
||||
ARGS=( "$@" )
|
||||
for ARG in "${ARGS[@]}"; do
|
||||
if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE"
|
||||
elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE"
|
||||
elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE"
|
||||
elif [ "$ARG" = "-ce" ] || [ "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE"
|
||||
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"
|
||||
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"
|
||||
if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-ce" ] || [ "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
|
||||
elif [ "$ARG" = "-i" ] || [ "$ARG" == "--init" ]; then create_sns_root; exit 0
|
||||
elif [ "$ARG" = "-i" ] || [ "$ARG" == "--init" ]; then init_store; exit 0
|
||||
else
|
||||
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
|
||||
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
|
||||
@@ -31,4 +31,5 @@
|
||||
NAME=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# w_conf and help are called here to avoid excess stage 3 code.
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
#==============================================================================
|
||||
# Section: Actions / Stage 3
|
||||
#==============================================================================
|
||||
# Default behavior
|
||||
# If no operation was specified, print help and exit on ERR_NO_OP
|
||||
if [ "$OP" != "TRUE" ]; then
|
||||
help; exit 20
|
||||
fi
|
||||
# All options not requiring at least a notebook to be specified have been dealt
|
||||
# with; if one isn't specified, throw code 30.
|
||||
# with; if one isn't specified, exit on ERR_NO_NOTEBOOK.
|
||||
if [ -z "$NOTEBOOK" ]; then
|
||||
printf "\n%s\n %s\n" "ERROR: Insufficient arguments:" "Notebook not specified"
|
||||
exit 30
|
||||
|
||||
Reference in New Issue
Block a user