aboutsummaryrefslogtreecommitdiffstats
path: root/mkhint
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-14 10:43:01 +0200
committerDanilo M. <danix@danix.xyz>2026-05-14 10:43:01 +0200
commitfed5a05be7d444378a8da5055d720d94e78c15e2 (patch)
tree7695ac561fe245e4975c63d3458578af61650193 /mkhint
parenta35a7805e97b115ae04181dce6cf940e546c7295 (diff)
downloadmkhintfile-fed5a05be7d444378a8da5055d720d94e78c15e2.tar.gz
mkhintfile-fed5a05be7d444378a8da5055d720d94e78c15e2.zip
refactor: switch arg parser to GNU getopt
Enables compound short flags (e.g. -Nn, -Nd). Also add short flags to bash completion candidates.
Diffstat (limited to 'mkhint')
-rwxr-xr-xmkhint24
1 files changed, 18 insertions, 6 deletions
diff --git a/mkhint b/mkhint
index 206bcf0..f64a202 100755
--- a/mkhint
+++ b/mkhint
@@ -314,8 +314,13 @@ clean_bak_files() {
# Main function
main() {
- # Parse command line arguments directly
- while [[ $# -gt 0 ]]; do
+ local parsed
+ parsed=$(getopt -o v:f:n:lcdNh \
+ --long version:,hintfile:,new:,list,clean,delete,no-dl,help \
+ -n 'mkhint' -- "$@") || { show_help; exit 1; }
+ eval set -- "$parsed"
+
+ while true; do
case "$1" in
--version|-v)
VERSION="$2"
@@ -338,11 +343,8 @@ main() {
shift
;;
--delete|-d)
+ COMMAND="delete"
shift
- while [[ $# -gt 0 && "$1" != -* ]]; do
- DELETE_HINT_FILES+=("$1")
- shift
- done
;;
--no-dl|-N)
NO_DL=1
@@ -352,6 +354,10 @@ main() {
COMMAND="help"
shift
;;
+ --)
+ shift
+ break
+ ;;
*)
echo "Unknown option: $1" >&2
show_help
@@ -360,6 +366,12 @@ main() {
esac
done
+ # Collect remaining positional args as delete targets
+ while [[ $# -gt 0 ]]; do
+ DELETE_HINT_FILES+=("$1")
+ shift
+ done
+
if [[ -z "$COMMAND" ]]; then
# Default to update hint file if VERSION and HINT_FILE are provided
if [[ -n "$VERSION" && -n "$HINT_FILE" ]]; then