mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Make sub matches show which commands are available under it
This commit is contained in:
+23
@@ -788,6 +788,25 @@ show_group_help() {
|
||||
fi
|
||||
}
|
||||
|
||||
show_prefix_help() {
|
||||
local prefix="$1"
|
||||
local prefix_with_space="$prefix "
|
||||
local key=""
|
||||
local rows=""
|
||||
|
||||
while IFS= read -r key; do
|
||||
[[ -n $key ]] || continue
|
||||
if [[ ${COMMAND_USAGE[$key]} == $prefix_with_space* ]]; then
|
||||
rows+="${COMMAND_USAGE[$key]}"$'\t'$'\t'"${COMMAND_SUMMARY[$key]}"$'\n'
|
||||
fi
|
||||
done < <(sorted_keys false)
|
||||
|
||||
[[ -n $rows ]] || return 1
|
||||
|
||||
echo "${prefix#omarchy } commands:"
|
||||
print_command_table "$rows"
|
||||
}
|
||||
|
||||
show_related_commands() {
|
||||
local key="$1"
|
||||
local group="${COMMAND_GROUP[$key]}"
|
||||
@@ -1005,6 +1024,10 @@ dispatch_or_help() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if show_prefix_help "omarchy ${args[*]}"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Unknown Omarchy command: omarchy ${args[*]}" >&2
|
||||
suggestion=$(suggest_command "${args[0]}")
|
||||
if [[ -n $suggestion ]]; then
|
||||
|
||||
@@ -100,6 +100,10 @@ output=$("$CLI" hw --help)
|
||||
assert_output_contains "hardware group help renders" "$output" "omarchy hw asus rog"
|
||||
assert_output_contains "hardware group includes touchpad" "$output" "omarchy hw touchpad"
|
||||
|
||||
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" menu --help)
|
||||
assert_output_contains "menu group includes share fallback route" "$output" "omarchy menu share"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user