diff --git a/bin/omarchy b/bin/omarchy index 08ccbc69d883..5a560ab077ea 100755 --- a/bin/omarchy +++ b/bin/omarchy @@ -135,7 +135,7 @@ remaining_has_help_flag() { for token in "$@"; do [[ $token == "--" ]] && break - [[ $token == "--help" || $token == "-h" ]] && return 0 + [[ $token == "--help" || $token == "-h" || $token == "?" ]] && return 0 done return 1 @@ -896,6 +896,18 @@ show_group_help() { show_prefix_help() { local prefix="$1" + local raw_words=() + local word="" + local prefix_words=() + + IFS=' ' read -r -a raw_words <<<"$prefix" + for word in "${raw_words[@]}"; do + [[ $word == "--help" || $word == "-h" || $word == "?" ]] && continue + prefix_words+=("$word") + done + (( ${#prefix_words[@]} >= 2 )) || return 1 + prefix=$(join_words " " "${prefix_words[@]}") + local prefix_with_space="$prefix " local key="" local rows="" @@ -1084,7 +1096,7 @@ dispatch_fast_or_help() { return 0 fi - if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" ]] && group_has_binary_commands "$1"; then + if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" || $2 == "?" ]] && group_has_binary_commands "$1"; then load_group_commands "$1" show_group_help "$1" return 0 @@ -1147,7 +1159,7 @@ dispatch_or_help() { return 0 fi - if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" ]] && group_exists "$1"; then + if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" || $2 == "?" ]] && group_exists "$1"; then show_group_help "$1" return 0 fi @@ -1172,7 +1184,7 @@ main() { fi case "$1" in - --help | -h) + --help | -h | "?") show_main_help ;; logout | reboot | shutdown) diff --git a/test/cli b/test/cli index b336e01da60f..3e94a968e96b 100755 --- a/test/cli +++ b/test/cli @@ -150,6 +150,21 @@ output=$("$CLI" hw asus) assert_output_contains "partial hardware prefix renders matching commands" "$output" "omarchy hw asus rog" assert_output_contains "partial hardware prefix includes nested match" "$output" "omarchy hw asus zenbook ux5406aa" +output=$("$CLI" theme bg --help) +assert_output_contains "intermediate prefix --help renders subcommands" "$output" "omarchy theme bg next" +assert_output_contains "intermediate prefix --help includes bg set" "$output" "omarchy theme bg set" + +output=$("$CLI" theme bg -h) +assert_output_contains "intermediate prefix -h renders subcommands" "$output" "omarchy theme bg next" + +make_tmpdir PREFIX_GLOB_TMPDIR +touch "$PREFIX_GLOB_TMPDIR/x" +output=$(cd "$PREFIX_GLOB_TMPDIR" && "$CLI" theme bg '?') +assert_output_contains "intermediate prefix ? ignores single-char filenames" "$output" "omarchy theme bg next" + +output=$("$CLI" theme '?') +assert_output_contains "group ? renders group help" "$output" "Theme commands" + # omarchy-agent takes only flags, so a word after it names the account # commands rather than reaching the agent launcher. output=$("$CLI" agent account)