diff options
| -rwxr-xr-x | mkhint | 24 | ||||
| -rw-r--r-- | mkhint.bash-completion | 2 |
2 files changed, 19 insertions, 7 deletions
@@ -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 diff --git a/mkhint.bash-completion b/mkhint.bash-completion index 8c52fb1..29e2523 100644 --- a/mkhint.bash-completion +++ b/mkhint.bash-completion @@ -8,7 +8,7 @@ _mkhintfile_completions() { repo_dir="/var/lib/sbopkg/SBo-danix" hint_dir="/etc/slackrepo/SBo-danix/hintfiles" - local all_flags="--version --hintfile --new --list --clean --delete --no-dl --help" + local all_flags="--version -v --hintfile -f --new -n --list -l --clean -c --delete -d --no-dl -N --help -h" case "$prev" in --new|-n) |
