aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-01-20 13:41:21 -0300
committerEuAndreh <eu@euandre.org>2022-01-20 16:35:19 -0300
commitea9dc340ec45c2aa6d2b319727a0b243e7cb9906 (patch)
treea412b64b053560cc7e0ddbc8d5e626416d311f86
parentsrc/td.in: Add missing option in Usage text (diff)
downloadtd-ea9dc340ec45c2aa6d2b319727a0b243e7cb9906.tar.gz
td-ea9dc340ec45c2aa6d2b319727a0b243e7cb9906.tar.xz
src/td.in: Add -F RC_FILE option for providing a file other than .tdrc
-rwxr-xr-xsrc/td.in48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/td.in b/src/td.in
index 22a289c..211b037 100755
--- a/src/td.in
+++ b/src/td.in
@@ -9,7 +9,7 @@ add_msg() {
MSG_USAGE="$(cat <<-'EOF'
Usage:
- @NAME@ [-c] [-m MESSAGE] [-t TYPE] [-s STATE]
+ @NAME@ [-c] [-m MESSAGE] [-t TYPE] [-s STATE] [-F RC_FILE]
@NAME@ [-HlL]
@NAME@ [-hV]
EOF
@@ -24,6 +24,7 @@ MSG_HELP1="$(cat <<-'EOF'
-m MESSAGE_TITLE the title message of the entry
-t TYPE the type of entry to be added (default: |TYPE|)
-s STATE the state of entry to be added (default: |STATE|)
+ -F RC_FILE use RC_FILE for config instead of .tdrc
-l list the supported values for $TD_USE_BUILTIN_HOOKS
-L lint the issues file
-H pre-process issues file before generating HTML
@@ -424,7 +425,7 @@ lint() {
#
-# Default values, config "run commands" file and derived values
+# Default values
#
ID="$(uuid)"
@@ -453,18 +454,6 @@ EOF
)"
export TD_HOOKS_DIR="$(mkdtemp)"
-if [ -r "$PWD/.tdrc" ]; then
- . "$PWD/.tdrc"
-fi
-
-DEFAULT_TYPE="$(echo "$TD_TYPES" | awk -F: '{ print $1; exit }')"
-DEFAULT_STATE="$(echo "$TD_STATES" | awk -F: '{ print $1; exit }')"
-TYPE="$DEFAULT_TYPE"
-STATE="$DEFAULT_STATE"
-NAME="$(name_for_type "$TYPE")"
-
-load_hooks
-
#
@@ -490,9 +479,35 @@ for flag in "$@"; do
esac
done
+OPTIONS='cm:t:s:F:lLHhV'
+
+RC_FILE="$PWD/.tdrc"
+while getopts ":$OPTIONS" flag; do
+ case "$flag" in
+ F)
+ RC_FILE="$OPTARG"
+ ;;
+ *)
+ ;;
+ esac
+done
+OPTIND=1
+
+if [ -r "$RC_FILE" ]; then
+ . "$RC_FILE"
+fi
+
+DEFAULT_TYPE="$(echo "$TD_TYPES" | awk -F: '{ print $1; exit }')"
+DEFAULT_STATE="$(echo "$TD_STATES" | awk -F: '{ print $1; exit }')"
+TYPE="$DEFAULT_TYPE"
+STATE="$DEFAULT_STATE"
+NAME="$(name_for_type "$TYPE")"
+
+load_hooks
+
SHORT=false
MESSAGE=FIXME
-while getopts 'cm:t:s:lLHhV' flag; do
+while getopts "$OPTIONS" flag; do
case "$flag" in
c)
SHORT=true
@@ -515,6 +530,9 @@ while getopts 'cm:t:s:lLHhV' flag; do
exit 1
fi
;;
+ F)
+ # already processed
+ ;;
l)
list_hooks
exit