Skip to content

Add completions for ZSH and Bash #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged
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
89 changes: 89 additions & 0 deletions completions/bash/framework_tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash

# Bash completion for framework_tool

_framework_tool() {
local options
options=(
"--flash-gpu-descriptor"
"-v" "--verbose"
"-q" "--quiet"
"--versions"
"--version"
"--features"
"--esrt"
"--device"
"--compare-version"
"--power"
"--thermal"
"--sensors"
"--pdports"
"--info"
"--pd-info"
"--dp-hdmi-info"
"--dp-hdmi-update"
"--audio-card-info"
"--privacy"
"--pd-bin"
"--ec-bin"
"--capsule"
"--dump"
"--ho2-capsule"
"--dump-ec-flash"
"--flash-ec"
"--flash-ro-ec"
"--flash-rw-ec"
"--intrusion"
"--inputmodules"
"--input-deck-mode"
"--charge-limit"
"--get-gpio"
"--fp-led-level"
"--fp-brightness"
"--kblight"
"--rgbkbd"
"--tablet-mode"
"--touchscreen-enable"
"--console"
"--reboot-ec"
"--hash"
"--driver"
"--pd-addrs"
"--pd-ports"
"--has-mec"
"-t" "--test"
"-h" "--help"
)

local devices=("bios" "ec" "pd0" "pd1" "rtm01" "rtm23" "ac-left" "ac-right")
local input_deck_modes=("auto" "off" "on")
local console_modes=("recent" "follow")
local drivers=("portio" "cros-ec" "windows")
local has_mec_options=("true" "false")
local brightness_options=("high" "medium" "low" "ultra-low")

local current_word prev_word
current_word="${COMP_WORDS[COMP_CWORD]}"
prev_word="${COMP_WORDS[COMP_CWORD-1]}"

# Handle options
if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=( $(compgen -W "${options[*]}" -- "$current_word") )
elif [[ $prev_word == "--device" ]]; then
COMPREPLY=( $(compgen -W "${devices[*]}" -- "$current_word") )
elif [[ $prev_word == "--input-deck-mode" ]]; then
COMPREPLY=( $(compgen -W "${input_deck_modes[*]}" -- "$current_word") )
elif [[ $prev_word == "--console" ]]; then
COMPREPLY=( $(compgen -W "${console_modes[*]}" -- "$current_word") )
elif [[ $prev_word == "--driver" ]]; then
COMPREPLY=( $(compgen -W "${drivers[*]}" -- "$current_word") )
elif [[ $prev_word == "--has-mec" ]]; then
COMPREPLY=( $(compgen -W "${has_mec_options[*]}" -- "$current_word") )
elif [[ $prev_word == "--fp-brightness" ]]; then
COMPREPLY=( $(compgen -W "${brightness_options[*]}" -- "$current_word") )
fi

return 0
}

complete -F _framework_tool framework_tool
56 changes: 56 additions & 0 deletions completions/zsh/_framework_tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#compdef framework_tool

local -a options

options=(
'--flash-gpu-descriptor[]'
'-v[Increase logging verbosity]'
'-q[Decrease logging verbosity]'
'--versions[Show current firmware versions]'
'--version[Show tool version information (Add -vv for more details)]'
'--features[Show features supported by the firmware]'
'--esrt[Display the UEFI ESRT table]'
'--device[Specify device type]:device:(bios ec pd0 pd1 rtm01 rtm23 ac-left ac-right)'
'--compare-version[Specify version to compare]:compare_version'
'--power[Show current power status of battery and AC (Add -vv for more details)]'
'--thermal[Print thermal information (Temperatures and Fan speed)]'
'--sensors[Print sensor information (ALS, G-Sensor)]'
'--pdports[Show information about USB-C PD ports]'
'--info[Show info from SMBIOS (Only on UEFI)]'
'--pd-info[Show details about the PD controllers]'
'--dp-hdmi-info[Show details about connected DP or HDMI Expansion Cards]'
'--dp-hdmi-update[Update the DisplayPort or HDMI Expansion Card]:update_bin'
'--audio-card-info[Show details about connected Audio Expansion Cards (Needs root privileges)]'
'--privacy[Show privacy switch statuses (camera and microphone)]'
'--pd-bin[Parse versions from PD firmware binary file]:pd_bin'
'--ec-bin[Parse versions from EC firmware binary file]:ec_bin'
'--capsule[Parse UEFI Capsule information from binary file]:capsule'
'--dump[Dump extracted UX capsule bitmap image to a file]:dump'
'--ho2-capsule[Parse UEFI Capsule information from binary file]:ho2_capsule'
'--dump-ec-flash[Dump EC flash contents]:dump_ec_flash'
'--flash-ec[Flash EC with new firmware from file]:flash_ec'
'--flash-ro-ec[Flash EC with new RO firmware from file]:flash_ro_ec'
'--flash-rw-ec[Flash EC with new RW firmware from file]:flash_rw_ec'
'--intrusion[Show status of intrusion switch]'
'--inputmodules[Show status of the input modules (Framework 16 only)]'
'--input-deck-mode[Set input deck power mode]:input_deck_mode:(auto off on)'
'--charge-limit[Get or set max charge limit]:charge_limit'
'--get-gpio[Get GPIO value by name]:get_gpio'
'--fp-led-level-gpio[Get or set fingerprint LED brightness level]:fp_led_level:(high medium low ultra-low auto)'
'--fp-brightness[Get or set fingerprint LED brightness]:fp_brightness'
'--kblight[Set keyboard backlight percentage or get, if no value provided]:kblight'
'--rgbkbd[Set the color of <key> to <RGB>.]'
'--tablet-mode[Set tablet mode override]:tablet_mode:(auto tablet laptop)'
'--touchscreen-enable[Enable/disable touchscreen]:touchscreen_enable:(true false)'
'--console[Get EC console, choose whether recent or to follow the output]:console:(recent follow)'
'--reboot-ec[Control EC RO/RW jump]:reboot_ec:(reboot jump-ro jump-rw cancel-jump disable-jump)'
'--hash[Hash a file of arbitrary data]:hash'
'--driver[Select which driver is used]:driver:(portio cros-ec windows)'
'--pd-addrs[Specify I2C addresses of the PD chips (Advanced)]:pd_addrs'
'--pd-ports[Specify I2C ports of the PD chips (Advanced)]:pd_ports'
'--has-mec[Specify the type of EC chip (MEC/MCHP or other)]:has_mec:(true false)'
'-t[Run self-test to check if interaction with EC is possible]'
'-h[Print help]'
)

_arguments -s -S $options