diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-07 18:58:35 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-07 18:59:20 +0200 |
| commit | 2841638a0146982322b53db7c305bdeb84456249 (patch) | |
| tree | 12ddae7a539c9b75f13fb71a325b8b34220df5aa | |
| parent | a6bbb96d31fb1df707ba3eea182e68b2f1c35552 (diff) | |
| download | mkhintfile-2841638a0146982322b53db7c305bdeb84456249.tar.gz mkhintfile-2841638a0146982322b53db7c305bdeb84456249.zip | |
feat: add --force flag (check-only, mutually exclusive elsewhere)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| -rwxr-xr-x | mkhint | 12 | ||||
| -rwxr-xr-x | tests/mkhint_test.sh | 16 |
2 files changed, 27 insertions, 1 deletions
@@ -59,6 +59,7 @@ SHOW_LIST="" RUN_REVIEW="" COMMAND="" NO_DL=0 +FORCE=0 # Show help message show_help() { @@ -1247,7 +1248,7 @@ check_updates() { main() { local parsed parsed=$(getopt -o vV:f:n:lcCdNhRF \ - --long version,set-version:,hintfile:,new:,list,clean,check,delete,no-dl,help,review,fix-current \ + --long version,set-version:,hintfile:,new:,list,clean,check,delete,no-dl,help,review,fix-current,force \ -n 'mkhint' -- "$@") || { show_help; exit 1; } eval set -- "$parsed" @@ -1297,6 +1298,10 @@ main() { NO_DL=1 shift ;; + --force) + FORCE=1 + shift + ;; --help|-h) COMMAND="help" shift @@ -1353,6 +1358,11 @@ main() { exit 1 fi + if [[ $FORCE -eq 1 && "$COMMAND" != "check" ]]; then + echo "Error: --force is only valid with --check" >&2 + exit 1 + fi + if [[ -n "$SHOW_LIST" && ${#LIST_PKGS[@]} -gt 0 ]]; then local p for p in "${LIST_PKGS[@]}"; do diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index 0d1553d..62e9f2f 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -1641,6 +1641,22 @@ echo "$out" | grep -qi 'manifest' \ || { echo " PASS: no manifest code for non-listed"; (( PASS++ )); } rm -f "$MOCK_BASE/manifest_fixture" "$MOCK_BASE/bundle-manifests" +# ── T-BM12: --force with --hintfile → exit 1 ───────────────────────────────── +echo "" +echo "T-BM12: --force is --check-only (errors with --hintfile/--new/--fix-current)" +set +e +o1=$(run_mkhint --force -f curl -V 1.0 2>&1); c1=$? +o2=$(run_mkhint --force -n curl 2>&1); c2=$? +o3=$(run_mkhint --force -F 2>&1); c3=$? +set -e +# grep the guard message too, so this pins our check rather than getopt's own rejection +[[ $c1 -eq 1 && $c2 -eq 1 && $c3 -eq 1 ]] \ + && echo "$o1" | grep -q 'only valid with --check' \ + && echo "$o2" | grep -q 'only valid with --check' \ + && echo "$o3" | grep -q 'only valid with --check' \ + && { echo " PASS: --force mutually exclusive"; (( PASS++ )); } \ + || { echo " FAIL: exits $c1 $c2 $c3"; (( FAIL++ )); ERRORS+=("T-BM12"); } + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown |
