aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-07 17:42:30 +0200
committerDanilo M. <danix@danix.xyz>2026-05-07 17:42:30 +0200
commit804a499754f5fec2db465effb174448d924e344e (patch)
tree7ab90f0361813aab8371a95e751fbe41f07762f1
parent03b2f896062ce689df655160328381004b3ad26d (diff)
downloadmkhintfile-master.tar.gz
mkhintfile-master.zip
rename mkhintfile.sh to mkhint, add --delete/-d optionHEADmaster
- Rename script and completion file to mkhint/mkhint.bash-completion - Add --delete/-d flag to remove one or more hint files (and .bak if present) - Fix bash completion: correct hint_dir path, use find for nested .info files, add --delete completion, add flag name completion - Update all references in CLAUDE.md, README.md, and source files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--CLAUDE.md20
-rw-r--r--README.md8
-rwxr-xr-xmkhint (renamed from mkhintfile.sh)71
-rw-r--r--mkhint.bash-completion37
-rw-r--r--mkhintfile.bash-completion33
5 files changed, 108 insertions, 61 deletions
diff --git a/CLAUDE.md b/CLAUDE.md
index 2ee689b..ea3e883 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4,11 +4,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## What This Is
-`mkhintfile.sh` — bash utility for managing [slackrepo](https://idlemoor.github.io/slackrepo/) hint files. Hint files override build variables (version, download URL, checksum) for SlackBuilds.
+`mkhint` — bash utility for managing [slackrepo](https://idlemoor.github.io/slackrepo/) hint files. Hint files override build variables (version, download URL, checksum) for SlackBuilds.
## Configuration
-Two paths hardcoded near top of `mkhintfile.sh` (lines 16–17):
+Two paths hardcoded near top of `mkhint` (lines 16–17):
```bash
REPO_DIR="/var/lib/sbopkg/SBo-danix/" # SBo repository with .info files
@@ -22,12 +22,12 @@ Bash completion script has its own hardcoded copies (lines 8–9) — keep in sy
No build step. Direct execution:
```bash
-bash mkhintfile.sh --help
-bash mkhintfile.sh --list
-bash mkhintfile.sh --version 2.0.1 --hintfile mypackage
-bash mkhintfile.sh --version 1.2.3 --new mypackage
-bash mkhintfile.sh --new mypackage # empty hint, no version
-bash mkhintfile.sh --clean
+bash mkhint --help
+bash mkhint --list
+bash mkhint --version 2.0.1 --hintfile mypackage
+bash mkhint --version 1.2.3 --new mypackage
+bash mkhint --new mypackage # empty hint, no version
+bash mkhint --clean
```
No test suite exists. Test manually against real `REPO_DIR`/`HINT_DIR` or with mock directories.
@@ -52,6 +52,6 @@ No test suite exists. Test manually against real `REPO_DIR`/`HINT_DIR` or with m
## Installation
```bash
-sudo cp mkhintfile.sh /usr/local/bin/mkhintfile
-sudo cp mkhintfile.bash-completion /etc/bash-completion.d/mkhintfile
+sudo cp mkhint /usr/local/bin/mkhint
+sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint
```
diff --git a/README.md b/README.md
index 5d04899..ffb5f85 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# mkhintfile.sh
+# mkhint
Manage hint files for slackrepo scripts. Updates version strings and download checksums, or creates new hint files from repository .info files.
@@ -7,18 +7,18 @@ Manage hint files for slackrepo scripts. Updates version strings and download ch
### Script
```bash
-sudo cp mkhintfile.sh /usr/local/bin/mkhintfile
+sudo cp mkhint /usr/local/bin/mkhint
```
### Bash Completion
```bash
-sudo cp mkhintfile.bash-completion /etc/bash-completion.d/mkhintfile
+sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint
```
### Configuration
-Edit the paths at the top of mkhintfile.sh to match your setup:
+Edit the paths at the top of mkhint to match your setup (lines 16–17):
```bash
REPO_DIR="/var/lib/sbopkg/SBo-danix" # Repository containing .info files
diff --git a/mkhintfile.sh b/mkhint
index 3b433b3..b3ccc75 100755
--- a/mkhintfile.sh
+++ b/mkhint
@@ -1,14 +1,15 @@
#!/bin/bash
-# mkhintfile.sh - Manage hint files for slackrepo scripts
+# mkhint - Manage hint files for slackrepo scripts
#
# Usage:
-# ./mkhintfile.sh --version VERSION --hintfile FILE Update existing hint file
-# ./mkhintfile.sh --version VERSION --new FILE Create new hint file
-# ./mkhintfile.sh --new FILE Create new hint file (no version)
-# ./mkhintfile.sh --list List hint files
-# ./mkhintfile.sh --clean Remove .bak files from HINT_DIR
-# ./mkhintfile.sh --help Show this help
+# ./mkhint --version VERSION --hintfile FILE Update existing hint file
+# ./mkhint --version VERSION --new FILE Create new hint file
+# ./mkhint --new FILE Create new hint file (no version)
+# ./mkhint --list List hint files
+# ./mkhint --clean Remove .bak files from HINT_DIR
+# ./mkhint --delete FILE Delete a hint file (and .bak if present)
+# ./mkhint --help Show this help
set -e
@@ -26,20 +27,21 @@ fi
VERSION=""
HINT_FILE=""
NEW_HINT_FILE=""
+DELETE_HINT_FILES=()
COMMAND=""
# Show help message
show_help() {
cat <<EOF
-mkhintfile.sh - Manage hint files for slackrepo scripts
+mkhint - Manage hint files for slackrepo scripts
Usage:
- ./mkhintfile.sh --version VERSION --hintfile FILE Update existing hint file
- ./mkhintfile.sh --version VERSION --new FILE Create new hint file
- ./mkhintfile.sh --new FILE Create new hint file (no version)
- ./mkhintfile.sh --list List hint files
- ./mkhintfile.sh --clean Remove .bak files from HINT_DIR
- ./mkhintfile.sh --help Show this help
+ ./mkhint --version VERSION --hintfile FILE Update existing hint file
+ ./mkhint --version VERSION --new FILE Create new hint file
+ ./mkhint --new FILE Create new hint file (no version)
+ ./mkhint --list List hint files
+ ./mkhint --clean Remove .bak files from HINT_DIR
+ ./mkhint --help Show this help
Options:
--version, -v VERSION New version string (required for --hintfile)
@@ -47,6 +49,7 @@ Options:
--new, -n FILE Create new hint file (required with --version or standalone)
--list, -l List all hint files in the default directory
--clean, -c Remove all .bak files from HINT_DIR
+ --delete, -d FILE Delete a hint file (and .bak if present)
--help, -h Show this help message
Hint files are stored in: $HINT_DIR
@@ -243,6 +246,32 @@ update_hint_file() {
echo; echo "=========================================="
}
+# Delete a hint file (and .bak if present)
+delete_hint_file() {
+ local file="$1"
+ local normalized_file="${file}"
+
+ if [[ "$file" != *.hint ]]; then
+ normalized_file="${file}.hint"
+ fi
+
+ local full_path="${HINT_DIR}/${normalized_file}"
+
+ if [[ ! -f "$full_path" ]]; then
+ echo "Error: Hint file does not exist: $full_path" >&2
+ exit 2
+ fi
+
+ rm "$full_path"
+ echo "Deleted: $full_path"
+
+ local bak_path="${full_path}.bak"
+ if [[ -f "$bak_path" ]]; then
+ rm "$bak_path"
+ echo "Deleted: $bak_path"
+ fi
+}
+
# Clean .bak files from HINT_DIR
clean_bak_files() {
if [[ ! -d "$HINT_DIR" ]]; then
@@ -286,6 +315,13 @@ main() {
COMMAND="clean"
shift
;;
+ --delete|-d)
+ shift
+ while [[ $# -gt 0 && "$1" != -* ]]; do
+ DELETE_HINT_FILES+=("$1")
+ shift
+ done
+ ;;
--help|-h)
COMMAND="help"
shift
@@ -304,6 +340,8 @@ main() {
COMMAND="update"
elif [[ -n "$NEW_HINT_FILE" ]]; then
COMMAND="new"
+ elif [[ ${#DELETE_HINT_FILES[@]} -gt 0 ]]; then
+ COMMAND="delete"
fi
fi
@@ -324,6 +362,11 @@ main() {
new)
create_new_hint_file "$NEW_HINT_FILE"
;;
+ delete)
+ for f in "${DELETE_HINT_FILES[@]}"; do
+ delete_hint_file "$f"
+ done
+ ;;
*)
echo "Error: Unknown command: $COMMAND" >&2
show_help
diff --git a/mkhint.bash-completion b/mkhint.bash-completion
new file mode 100644
index 0000000..43a64ae
--- /dev/null
+++ b/mkhint.bash-completion
@@ -0,0 +1,37 @@
+# bash completion for mkhint
+# Install: sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint
+
+_mkhintfile_completions() {
+ local cur prev repo_dir hint_dir
+ _init_completion || return
+
+ repo_dir="/var/lib/sbopkg/SBo-danix"
+ hint_dir="/etc/slackrepo/SBo-danix/hintfiles"
+
+ local all_flags="--version --hintfile --new --list --clean --delete --help"
+
+ case "$prev" in
+ --new|-n)
+ local -a words=()
+ while IFS= read -r f; do
+ words+=("$(basename "${f%.info}")")
+ done < <(find "$repo_dir" -mindepth 2 -maxdepth 2 -name "*.info" 2>/dev/null)
+ COMPREPLY=($(compgen -W "${words[*]}" -- "$cur"))
+ ;;
+ --hintfile|-f|--delete|-d)
+ local -a words=()
+ for f in "$hint_dir"/*.hint; do
+ [[ -f "$f" ]] && words+=("$(basename "${f%.hint}")")
+ done
+ COMPREPLY=($(compgen -W "${words[*]}" -- "$cur"))
+ ;;
+ --version|-v)
+ # no completion, raw text
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "$all_flags" -- "$cur"))
+ ;;
+ esac
+}
+
+complete -F _mkhintfile_completions mkhintfile.sh mkhintfile
diff --git a/mkhintfile.bash-completion b/mkhintfile.bash-completion
deleted file mode 100644
index e217edf..0000000
--- a/mkhintfile.bash-completion
+++ /dev/null
@@ -1,33 +0,0 @@
-# bash completion for mkhintfile.sh
-# Install: sudo cp mkhintfile.bash-completion /etc/bash-completion.d/mkhintfile
-
-_mkhintfile_completions() {
- local cur prev repo_dir hint_dir
- _init_completion || return
-
- repo_dir="/var/lib/sbopkg/SBo-danix"
- hint_dir="/tmp/hintdir"
-
- case "$prev" in
- --new|-n)
- local -a words=()
- for f in "$repo_dir"/*.info; do
- [[ -f "$f" ]] && words+=("$(basename "${f%.info}")")
- done
- COMPREPLY=($(compgen -W "${words[*]}" -- "$cur"))
- ;;
- --hintfile|-f)
- local -a words=()
- for f in "$hint_dir"/*.hint; do
- [[ -f "$f" ]] && words+=("$(basename "${f%.hint}")")
- done
- COMPREPLY=($(compgen -W "${words[*]}" -- "$cur"))
- ;;
- # --version (no completion, raw text)
- # --list, --help (no value completion, flags only)
- *)
- ;;
- esac
-}
-
-complete -F _mkhintfile_completions mkhintfile.sh