Environment variables override config, flags override environment variables
* Added more flags to give action developers more control over commands that are leveraged inside their actions. * Writing a better message for the help screen
This commit is contained in:
committed by
Gina Trapani
parent
0c5bdf3b0a
commit
dae6f2bcaf
87
todo.sh
87
todo.sh
@@ -185,6 +185,8 @@ help()
|
|||||||
-+
|
-+
|
||||||
Hide project names in list output. Use twice to show project
|
Hide project names in list output. Use twice to show project
|
||||||
names (default).
|
names (default).
|
||||||
|
-c
|
||||||
|
Color mode
|
||||||
-d CONFIG_FILE
|
-d CONFIG_FILE
|
||||||
Use a configuration file other than the default ~/.todo/config
|
Use a configuration file other than the default ~/.todo/config
|
||||||
-f
|
-f
|
||||||
@@ -198,12 +200,19 @@ help()
|
|||||||
priority labels (default).
|
priority labels (default).
|
||||||
-a
|
-a
|
||||||
Don't auto-archive tasks automatically on completion
|
Don't auto-archive tasks automatically on completion
|
||||||
|
-A
|
||||||
|
Auto-archive tasks automatically on completion
|
||||||
-n
|
-n
|
||||||
Don't preserve line numbers; automatically remove blank lines
|
Don't preserve line numbers; automatically remove blank lines
|
||||||
on task deletion
|
on task deletion
|
||||||
|
-N
|
||||||
|
Preserve line numbers
|
||||||
-t
|
-t
|
||||||
Prepend the current date to a task automatically
|
Prepend the current date to a task automatically
|
||||||
when it's added.
|
when it's added.
|
||||||
|
-T
|
||||||
|
Do not prepend the current date to a task automatically
|
||||||
|
when it's added.
|
||||||
-v
|
-v
|
||||||
Verbose mode turns on confirmation messages
|
Verbose mode turns on confirmation messages
|
||||||
-vv
|
-vv
|
||||||
@@ -215,12 +224,12 @@ help()
|
|||||||
|
|
||||||
|
|
||||||
Environment variables:
|
Environment variables:
|
||||||
TODOTXT_AUTO_ARCHIVE=0 is same as option -a
|
TODOTXT_AUTO_ARCHIVE is same as option -a (0)/-A (1)
|
||||||
TODOTXT_CFG_FILE=CONFIG_FILE is same as option -d CONFIG_FILE
|
TODOTXT_CFG_FILE=CONFIG_FILE is same as option -d CONFIG_FILE
|
||||||
TODOTXT_FORCE=1 is same as option -f
|
TODOTXT_FORCE=1 is same as option -f
|
||||||
TODOTXT_PRESERVE_LINE_NUMBERS=0 is same as option -n
|
TODOTXT_PRESERVE_LINE_NUMBERS is same as option -n (0)/-N (1)
|
||||||
TODOTXT_PLAIN=1 is same as option -p
|
TODOTXT_PLAIN is same as option -p (1)/-c (0)
|
||||||
TODOTXT_DATE_ON_ADD=1 is same as option -t
|
TODOTXT_DATE_ON_ADD is same as option -t (1)/-T (0)
|
||||||
TODOTXT_VERBOSE=1 is same as option -v
|
TODOTXT_VERBOSE=1 is same as option -v
|
||||||
TODOTXT_DEFAULT_ACTION="" run this when called with no arguments
|
TODOTXT_DEFAULT_ACTION="" run this when called with no arguments
|
||||||
TODOTXT_SORT_COMMAND="sort ..." customize list output
|
TODOTXT_SORT_COMMAND="sort ..." customize list output
|
||||||
@@ -343,8 +352,20 @@ replaceOrPrepend()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Preserving environment variables so they don't get clobbered by the config file
|
||||||
|
OVR_TODOTXT_AUTO_ARCHIVE="$TODOTXT_AUTO_ARCHIVE"
|
||||||
|
OVR_TODOTXT_FORCE="$TODOTXT_FORCE"
|
||||||
|
OVR_TODOTXT_PRESERVE_LINE_NUMBERS="$TODOTXT_PRESERVE_LINE_NUMBERS"
|
||||||
|
OVR_TODOTXT_PLAIN="$TODOTXT_PLAIN"
|
||||||
|
OVR_TODOTXT_DATE_ON_ADD="$TODOTXT_DATE_ON_ADD"
|
||||||
|
OVR_TODOTXT_DISABLE_FILTER="$TODOTXT_DISABLE_FILTER"
|
||||||
|
OVR_TODOTXT_VERBOSE="$TODOTXT_VERBOSE"
|
||||||
|
OVR_TODOTXT_DEFAULT_ACTION="$TODOTXT_DEFAULT_ACTION"
|
||||||
|
OVR_TODOTXT_SORT_COMMAND="$TODOTXT_SORT_COMMAND"
|
||||||
|
OVR_TODOTXT_FINAL_FILTER="$TODOTXT_FINAL_FILTER"
|
||||||
|
|
||||||
# == PROCESS OPTIONS ==
|
# == PROCESS OPTIONS ==
|
||||||
while getopts ":fhpnatvVx+@Pd:" Option
|
while getopts ":fhpcnNaAtTvVx+@Pd:" Option
|
||||||
do
|
do
|
||||||
case $Option in
|
case $Option in
|
||||||
'@' )
|
'@' )
|
||||||
@@ -380,22 +401,31 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
a )
|
a )
|
||||||
TODOTXT_AUTO_ARCHIVE=0
|
OVR_TODOTXT_AUTO_ARCHIVE=0
|
||||||
|
;;
|
||||||
|
A )
|
||||||
|
OVR_TODOTXT_AUTO_ARCHIVE=1
|
||||||
|
;;
|
||||||
|
c )
|
||||||
|
OVR_TODOTXT_PLAIN=0
|
||||||
;;
|
;;
|
||||||
d )
|
d )
|
||||||
TODOTXT_CFG_FILE=$OPTARG
|
TODOTXT_CFG_FILE=$OPTARG
|
||||||
;;
|
;;
|
||||||
f )
|
f )
|
||||||
TODOTXT_FORCE=1
|
OVR_TODOTXT_FORCE=1
|
||||||
;;
|
;;
|
||||||
h )
|
h )
|
||||||
shorthelp
|
shorthelp
|
||||||
;;
|
;;
|
||||||
n )
|
n )
|
||||||
TODOTXT_PRESERVE_LINE_NUMBERS=0
|
OVR_TODOTXT_PRESERVE_LINE_NUMBERS=0
|
||||||
|
;;
|
||||||
|
N )
|
||||||
|
OVR_TODOTXT_PRESERVE_LINE_NUMBERS=1
|
||||||
;;
|
;;
|
||||||
p )
|
p )
|
||||||
TODOTXT_PLAIN=1
|
OVR_TODOTXT_PLAIN=1
|
||||||
;;
|
;;
|
||||||
P )
|
P )
|
||||||
## HIDE_PRIORITY_LABELS starts at zero (false); increment it to one
|
## HIDE_PRIORITY_LABELS starts at zero (false); increment it to one
|
||||||
@@ -414,7 +444,10 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
t )
|
t )
|
||||||
TODOTXT_DATE_ON_ADD=1
|
OVR_TODOTXT_DATE_ON_ADD=1
|
||||||
|
;;
|
||||||
|
T )
|
||||||
|
OVR_TODOTXT_DATE_ON_ADD=0
|
||||||
;;
|
;;
|
||||||
v )
|
v )
|
||||||
: $(( TODOTXT_VERBOSE++ ))
|
: $(( TODOTXT_VERBOSE++ ))
|
||||||
@@ -423,7 +456,7 @@ do
|
|||||||
version
|
version
|
||||||
;;
|
;;
|
||||||
x )
|
x )
|
||||||
TODOTXT_DISABLE_FILTER=1
|
OVR_TODOTXT_DISABLE_FILTER=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -527,6 +560,38 @@ fi
|
|||||||
|
|
||||||
. "$TODOTXT_CFG_FILE"
|
. "$TODOTXT_CFG_FILE"
|
||||||
|
|
||||||
|
# === APPLY OVERRIDES
|
||||||
|
if [ -n "$OVR_TODOTXT_AUTO_ARCHIVE" ] ; then
|
||||||
|
TODOTXT_AUTO_ARCHIVE="$OVR_TODOTXT_AUTO_ARCHIVE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_FORCE" ] ; then
|
||||||
|
TODOTXT_FORCE="$OVR_TODOTXT_FORCE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_PRESERVE_LINE_NUMBERS" ] ; then
|
||||||
|
TODOTXT_PRESERVE_LINE_NUMBERS="$OVR_TODOTXT_PRESERVE_LINE_NUMBERS"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_PLAIN" ] ; then
|
||||||
|
TODOTXT_PLAIN="$OVR_TODOTXT_PLAIN"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_DATE_ON_ADD" ] ; then
|
||||||
|
TODOTXT_DATE_ON_ADD="$OVR_TODOTXT_DATE_ON_ADD"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_DISABLE_FILTER" ] ; then
|
||||||
|
TODOTXT_DISABLE_FILTER="$OVR_TODOTXT_DISABLE_FILTER"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_VERBOSE" ] ; then
|
||||||
|
TODOTXT_VERBOSE="$OVR_TODOTXT_VERBOSE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_DEFAULT_ACTION" ] ; then
|
||||||
|
TODOTXT_DEFAULT_ACTION="$OVR_TODOTXT_DEFAULT_ACTION"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_SORT_COMMAND" ] ; then
|
||||||
|
TODOTXT_SORT_COMMAND="$OVR_TODOTXT_SORT_COMMAND"
|
||||||
|
fi
|
||||||
|
if [ -n "$OVR_TODOTXT_FINAL_FILTER" ] ; then
|
||||||
|
TODOTXT_FINAL_FILTER="$OVR_TODOTXT_FINAL_FILTER"
|
||||||
|
fi
|
||||||
|
|
||||||
ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|
ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|
||||||
|
|
||||||
[ -z "$ACTION" ] && usage
|
[ -z "$ACTION" ] && usage
|
||||||
|
|||||||
Reference in New Issue
Block a user