aboutsummaryrefslogtreecommitdiff
path: root/ctct.in
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-12-24 18:41:03 +0100
committerEinhard Leichtfuß <alguien@respiranto.de>2018-12-24 18:50:12 +0100
commitf440a9c21188195ad111cf01d4e00c0874e72bb1 (patch)
tree8c77ca3d8166ed4176a9941d21f3a6b19bfd016a /ctct.in
parent84ed06fc7c31e493e627923bb06abd0ef2a3c27b (diff)
Improve ctct(1)
- Try to conform to man-pages(7). `- Try to avoid technical information. `- Remove the CONFIGURATION section. It's contents are to reappear in ctct_config(5) which ctct(1) already references. - Add some commented blank lines to improve readability. Also, in the main script: - Add EXIT_* variables. Not yet used. - Improve the naming in the help output. - Stop option parsing on '--'. - In the default case (i.e. no special option), return 1 if only a non exact match was found.
Diffstat (limited to 'ctct.in')
-rw-r--r--ctct.in16
1 files changed, 12 insertions, 4 deletions
diff --git a/ctct.in b/ctct.in
index 93c5ff2..ef7b588 100644
--- a/ctct.in
+++ b/ctct.in
@@ -38,6 +38,9 @@ test -f "$user_config_dir/config.sh" \
## CONSTANTS:
exec_name="${0##*/}"
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_ERROR=2
TRUE=0
FALSE=1
@@ -47,8 +50,8 @@ cat << EOF
usage:
$exec_name <name> - show contact
$exec_name -l - list all entries
- $exec_name [-s] <part> [...] - search by name
- $exec_name -S <part> [...] - search by data
+ $exec_name -s <pattern> [...] - search by name
+ $exec_name -S <regex> [...] - search by data
$exec_name -e <name> - edit / create entry
$exec_name -d <name> [...] - delete entries
$exec_name --rename <old> <new> - rename entry
@@ -107,7 +110,12 @@ function main()
( test $# -lt 3 && print_error "$exec_name: no new name specified." ) \
&& exit 1
rename_file "$2" "$3"; exit $?
- elif [[ "$1" =~ ^- ]]; then
+ elif [[ "$1" == '--' ]]
+ then
+ shift 1
+ test $# -eq 0 && print_help && exit 1
+ elif [[ "$1" =~ ^- ]]
+ then
print_error "$exec_name: unknown option '$1'"; exit 1
fi
@@ -116,8 +124,8 @@ function main()
if ! find_similar "Did you mean:" "$@"
then
print_msg "No match found."
- return 1
fi
+ return 1
fi
}