Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions bin/omarchy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[@]}")
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

local prefix_with_space="$prefix "
local key=""
local rows=""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -1172,7 +1184,7 @@ main() {
fi

case "$1" in
--help | -h)
--help | -h | "?")
show_main_help
;;
logout | reboot | shutdown)
Expand Down
15 changes: 15 additions & 0 deletions test/cli
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down