fix(completion): clean up code

- reformat code
- remove redundant functions
This commit is contained in:
EmilyGraceSeville7cf 2024-09-30 01:42:20 +10:00
parent 1a1169fece
commit de426323be
25 changed files with 204 additions and 528 deletions

View file

@ -1,19 +1,13 @@
set command termux-call-log
set -l command termux-call-log
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s l -x \
-a '10\tdefault' \
-s l \
-d 'Limit the amount of listed calls' \
-x
-d 'Limit the amount of listed calls'
complete -c $command \
complete -c $command -s o -x \
-a '0\tdefault' \
-s o \
-d 'Start listing calls with the specified one' \
-x
-d 'Start listing calls with the specified one'

View file

@ -1,13 +1,9 @@
set command termux-camera-photo
set -l command termux-camera-photo
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s c -x \
-a '(__fish_termux_api__complete_camera_ids)' \
-s c \
-d 'Specify the ID of a camera' \
-x
-d 'Specify the ID of a camera'

View file

@ -1,21 +1,11 @@
set command termux-dialog
set -l command termux-dialog
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s l \
-l list \
-d 'List all widgets and their options'
complete -c $command \
-s t \
-l title \
-d 'Specify the title of a dialog' \
-x
complete -c $command -s l -l list -d 'List all widgets and their options'
complete -c $command -s t -l title -x -d 'Specify the title of a dialog'
set subcommands_with_descriptions 'confirm\t"Show a confirmation"' \
'checkbox\t"Select multiple values using checkboxes"' \
@ -30,48 +20,36 @@ set subcommands_with_descriptions 'confirm\t"Show a confirmation"' \
set subcommands (string replace --regex '\\\t.+' '' -- $subcommands_with_descriptions)
complete -c $command \
-a "$subcommands_with_descriptions" \
-n "not __fish_seen_subcommand_from $subcommands" \
complete -c $command -a "$subcommands_with_descriptions" \
-n "not __fish_seen_subcommand_from $subcommands"
complete -c $command \
-s i \
complete -c $command -s i -x \
-d "Specify the text hint of a dialog" \
-n "__fish_seen_subcommand_from confirm speech text" \
-x
-n "__fish_seen_subcommand_from confirm speech text"
complete -c $command \
-s v \
complete -c $command -s v -x \
-d "Specify the comma delimited choices of a dialog" \
-n "__fish_seen_subcommand_from checkbox radio sheet spinner" \
-x
-n "__fish_seen_subcommand_from checkbox radio sheet spinner"
complete -c $command \
-s r \
complete -c $command -s r -x \
-d "Specify the number range of a dialog" \
-n "__fish_seen_subcommand_from counter" \
-x
-n "__fish_seen_subcommand_from counter"
complete -c $command \
complete -c $command -s d -x \
-a '"dd-MM-yyyy k:m:s"\tdefault' \
-s d \
-d "Specify the date format of a dialog" \
-n "__fish_seen_subcommand_from date" \
-x
-n "__fish_seen_subcommand_from date"
set text_condition "__fish_seen_subcommand_from text"
complete -c $command \
-s m \
complete -c $command -s m \
-d "Enable the multiline input mode in a dialog" \
-n "$text_condition; and not __fish_seen_argument -s n"
complete -c $command \
-s n \
complete -c $command -s n \
-d "Enable the number input mode in a dialog" \
-n "$text_condition; and not __fish_seen_argument -s m"
complete -c $command \
-s p \
complete -c $command -s p \
-d "Enable the password input mode in a dialog" \
-n $text_condition

View file

@ -1,22 +1,11 @@
set command termux-download
set -l command termux-download
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s d \
-d 'Specify the description for a download notification' \
-x
complete -c $command -s d -x \
-d 'Specify the description for a download notification'
complete -c $command \
-s t \
-d 'Specify the title for a download notification' \
-x
complete -c $command \
-s p \
-d 'Specify the path for a download' \
-F -r
complete -c $command -s t -x -d 'Specify the title for a download notification'
complete -c $command -s p -F -r -d 'Specify the path for a download'

View file

@ -1,12 +1,7 @@
set command termux-infrared-transmit
set -l command termux-infrared-transmit
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s f \
-d 'Specify the IR carrier frequency' \
-x
complete -c $command -s f -x -d 'Specify the IR carrier frequency'

View file

@ -1,72 +1,37 @@
set command termux-job-scheduler
set -l command termux-job-scheduler
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s p \
-l pending \
-d 'List pending jobs'
complete -c $command -s p -l pending -d 'List pending jobs'
complete -c $command -l cancel-all -d 'Cancel all pending jobs'
complete -c $command -s s -l script -r -d 'Specify a script path to schedule'
complete -c $command -l job-id -x -d 'Specify the ID of a job'
complete -c $command \
-l cancel-all \
-d 'Cancel all pending jobs'
complete -c $command \
-s s \
-l script \
-d 'Specify a script path to schedule' \
-r
complete -c $command \
-l job-id \
-d 'Specify the ID of a job' \
-x
complete -c $command \
complete -c $command -l period-ms -x \
-a '0\tdefault' \
-l period-ms \
-d 'Specify the interval between script runs' \
-x
-d 'Specify the interval between script runs'
complete -c $command \
complete -c $command -l network -x \
-a 'any\tdefault unmetered cellular not_roaming none' \
-l network \
-d 'Require the network of a specific type to be available' \
-x
-d 'Require the network of a specific type to be available'
complete -c $command \
complete -c $command -l battery-not-low -x \
-a 'true\tdefault false' \
-l battery-not-low \
-d 'Whether run a script when a battery is low' \
-x
-d 'Whether run a script when a battery is low'
complete -c $command \
complete -c $command -l storage-not-low -x \
-a 'false\tdefault true' \
-l storage-not-low \
-d 'Whether run a script when a storage is low' \
-x
-d 'Whether run a script when a storage is low'
complete -c $command \
complete -c $command -l charging -x \
-a 'false\tdefault true' \
-l charging \
-d 'Whether run a script when the device is charging' \
-x
-d 'Whether run a script when the device is charging'
complete -c $command \
complete -c $command -l persisted -x \
-a 'false\tdefault true' \
-l persisted \
-d 'Whether unschedule script on reboots' \
-x
-d 'Whether unschedule script on reboots'
complete -c $command \
-l trigger-content-uri \
-x
complete -c $command \
-a '1\tdefault' \
-l trigger-content-flag \
-x
complete -c $command -l trigger-content-uri -x
complete -c $command -l trigger-content-flag -x -a '1\tdefault'

View file

@ -1,19 +1,13 @@
set command termux-location
set -l command termux-location
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s p -x \
-a 'gps\tdefault network passive' \
-s p \
-d 'Specify the provider of a location' \
-x
-d 'Specify the provider of a location'
complete -c $command \
complete -c $command -s r -x \
-a 'once\tdefault last updates' \
-s r \
-d 'Specify the request type for a location' \
-x
-d 'Specify the request type for a location'

View file

@ -1,10 +1,8 @@
set command termux-media-player
set -l command termux-media-player
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
set subcommands_with_descriptions 'info\t"Show a current playback information"' \
'play\t"Resume a playback if paused | Play a specific media file"' \
@ -13,10 +11,8 @@ set subcommands_with_descriptions 'info\t"Show a current playback information"'
set subcommands (string replace --regex '\\\t.+' '' -- $subcommands_with_descriptions)
complete -c $command \
-a "$subcommands_with_descriptions" \
complete -c $command -a "$subcommands_with_descriptions" \
-n "not __fish_seen_subcommand_from $subcommands"
complete -c $command \
-n "__fish_seen_subcommand_from play" \
-F -r
complete -c $command -F -r \
-n "__fish_seen_subcommand_from play"

View file

@ -1,13 +1,6 @@
set command termux-media-scan
set -l command termux-media-scan
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s r \
-d 'Scan directories recursively'
complete -c $command \
-s v \
-d 'Show verbose messages'
complete -c $command -s r -d 'Scan directories recursively'
complete -c $command -s v -d 'Show verbose messages'

View file

@ -1,51 +1,22 @@
set command termux-microphone-record
set -l command termux-microphone-record
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s d \
-d Record
complete -c $command -s d -d Record
complete -c $command -s f -F -r -d 'Specify a file to save recording to'
complete -c $command \
-s f \
-d 'Specify a file to save recording to' \
-F -r
complete -c $command \
complete -c $command -s l -x \
-a '0\tdefault' \
-s l \
-d 'Specify the length limit of a recording' \
-x
-d 'Specify the length limit of a recording'
complete -c $command \
complete -c $command -s e -x \
-a 'aac amr_wb amr_nb' \
-s e \
-d 'Specify the encoder of a recording' \
-x
-d 'Specify the encoder of a recording'
complete -c $command \
-s b \
-d 'Specify the bitrate of a recording' \
-x
complete -c $command \
-s r \
-d 'Specify the sampling rate of a recording' \
-x
complete -c $command \
-s c \
-d 'Specify the channel count of a recording' \
-x
complete -c $command \
-s i \
-d 'Show information about the current recording'
complete -c $command \
-s q \
-d 'Quit the current recording'
complete -c $command -s b -x -d 'Specify the bitrate of a recording'
complete -c $command -s r -x -d 'Specify the sampling rate of a recording'
complete -c $command -s c -x -d 'Specify the channel count of a recording'
complete -c $command -s i -d 'Show information about the current recording'
complete -c $command -s q -d 'Quit the current recording'

View file

@ -1,12 +1,7 @@
set command termux-notification-remove
set -l command termux-notification-remove
complete -c $command -f
complete -c $command \
-s h \
-l help \
-d 'Show help'
complete -c $command -s h -l help -d 'Show help'
complete -c $command \
-a '(__fish_termux_api__complete_group_ids)' \
-x
complete -c $command -a '(__fish_termux_api__complete_group_ids)' -x

View file

@ -1,123 +1,80 @@
set command termux-notification
set -l command termux-notification
complete -c $command -f
complete -c $command \
-s h \
-l help \
-d 'Show help'
complete -c $command -s h -l help -d 'Show help'
complete -c $command \
-l action \
-d 'Specify the action when pressing a notification' \
-F -r
complete -c $command -l action -F -r \
-d 'Specify the action when pressing a notification'
complete -c $command \
-l alert-once \
complete -c $command -l alert-once \
-d 'Do not alert when a notification is edited'
set button_names first second third
set index 1
while test $index -le (count $button_names)
complete -c $command \
-l button$index \
-d "Specify the text of a $button_names[$index] notification button" \
-x
complete -c $command -l button$index -x \
-d "Specify the text of a $button_names[$index] notification button"
complete -c $command \
-l button$index-action \
-d "Specify the action of a $button_names[$index] notification button" \
-F -r
complete -c $command -l button$index-action -F -r \
-d "Specify the action of a $button_names[$index] notification button"
set index (math $index + 1)
end
complete -c $command \
-s c \
-l content \
-d 'Specify the content of a notification' \
-x
complete -c $command -s c -l content -x \
-d 'Specify the content of a notification'
complete -c $command \
complete -c $command -l group -x \
-a '(__fish_termux_api__complete_group_ids)' \
-l group \
-d 'Specify the group of a notification' \
-x
-d 'Specify the group of a notification'
complete -c $command \
-l help-actions \
complete -c $command -l help-actions \
-d 'Show help for the actions of a notification'
complete -c $command \
-s i \
-l id \
-d 'Specify the identifier of a notification' \
-x
complete -c $command -s i -l id -x \
-d 'Specify the identifier of a notification'
complete -c $command \
-l image-path \
-d 'Specify the image of a notification' \
-F -r
complete -c $command -l image-path -F -r \
-d 'Specify the image of a notification'
complete -c $command \
complete -c $command -l led-color -x \
-a 'none\tdefault' \
-l led-color \
-d 'Specify the LED color of a notification' \
-x
-d 'Specify the LED color of a notification'
set led_states on off
for state in $led_states
complete -c $command \
complete -c $command -l led-$state -x \
-a '800\tdefault' \
-l led-$state \
-d "Specify the time for the LED to be $state while flashing of a notification" \
-x
-d "Specify the time for the LED to be $state while flashing of a notification"
end
complete -c $command \
-l on-delete \
-d 'Specify the action when a notification is cleared' \
-F -r
complete -c $command -l on-delete -F -r \
-d 'Specify the action when a notification is cleared'
complete -c $command \
-l ongoing \
-d 'Pin a notification'
complete -c $command -l ongoing -d 'Pin a notification'
complete -c $command \
complete -c $command -l priority -x \
-a 'default\tdefault high low max min' \
-l priority \
-d 'Specify the priority of a notification' \
-x
-d 'Specify the priority of a notification'
complete -c $command \
-l sound \
-d 'Play the sound with a notification'
complete -c $command -l sound -d 'Play the sound with a notification'
complete -c $command -s t -l title -x -d 'Specify the title of a notification'
complete -c $command \
-s t \
-l title \
-d 'Specify the title of a notification' \
-x
complete -c $command -l vibrate -x \
-d 'Specify the vibrate pattern of a notification'
complete -c $command \
-l vibrate \
-d 'Specify the vibrate pattern of a notification' \
-x
complete -c $command \
complete -c $command -l type -x \
-a 'default\tdefault media' \
-l type \
-d 'Specify the style of a notification' \
-x
-d 'Specify the style of a notification'
set media_options next pause play previous
for option in $media_options
complete -c $command \
-l media-$option \
complete -c $command -l media-$option -F -r \
-d "Specify the action for $option button a notification" \
-n '__fish_seen_argument -l type' \
-F -r
-n '__fish_seen_argument -l type'
end

View file

@ -1,61 +1,20 @@
function __fish_termux_api__complete_sensor_ids_as_list
set ids (__fish_termux_api__complete_sensor_ids)
set token (commandline -t -c)
set delimiter ,
switch "$token"
case '*,'
set delimiter
end
test -z "$token" && set delimiter
for id in $ids
string unescape -- "$token$delimiter$id"
end
end
set command termux-sensor
set -l command termux-sensor
complete -c $command -f
complete -c $command \
-s h \
-l help \
-d 'Show help'
complete -c $command -s h -l help -d 'Show help'
complete -c $command \
-s a \
-l all \
-d 'Listen to all sensors'
complete -c $command -s a -l all -d 'Listen to all sensors'
complete -c $command -s c -l cleanup -d 'Release sensor resources'
complete -c $command -s l -l list -d 'List sensors'
complete -c $command \
-s c \
-l cleanup \
-d 'Release sensor resources'
complete -c $command -s s -l sensors -x \
-a '(__fish_complete_list , __fish_termux_api__complete_sensor_ids)' \
-d 'Specify comma-separated sensors to listen to'
complete -c $command \
-s l \
-l list \
-d 'List sensors'
complete -c $command -s d -l delay -x \
-d 'Specify the delay between sensor updates'
complete -c $command \
-a '(__fish_termux_api__complete_sensor_ids_as_list)' \
-s s \
-l sensors \
-d 'Specify comma-separated sensors to listen to' \
-x
complete -c $command \
-s d \
-l delay \
-d 'Specify the delay between sensor updates' \
-x
complete -c $command \
complete -c $command -s n -l limit -x \
-a 'continuous\tdefault' \
-s n \
-l limit \
-d 'Specify a number of times to read senors' \
-x
-d 'Specify a number of times to read senors'

View file

@ -1,28 +1,17 @@
set command termux-share
set -l command termux-share
complete -c $command -f
complete -c $command \
-s h \
-l help \
-d 'Show help'
complete -c $command -s h -l help -d 'Show help'
complete -c $command \
complete -c $command -s a -x \
-a 'view\tdefault edit send' \
-s a \
-d 'Specify the action to perform on a content' \
-x
-d 'Specify the action to perform on a content'
complete -c $command \
complete -c $command -s c \
-a 'text/plain\tdefault' \
-s c \
-d 'Specify the type of a content'
complete -c $command \
-s d \
-d 'Specify the receiver of a content'
complete -c $command \
-s t \
-d 'Specify the title of a content' \
-x
complete -c $command -s d -d 'Specify the receiver of a content'
complete -c $command -s t -x -d 'Specify the title of a content'

View file

@ -1,33 +1,21 @@
set command termux-sms-list
set -l command termux-sms-list
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s d \
-d 'Show the creation dates of listed messages'
complete -c $command -s d -d 'Show the creation dates of listed messages'
complete -c $command \
complete -c $command -s l -x \
-a '10\tdefault' \
-s l \
-d 'Limit the amount of listed messages' \
-x
-d 'Limit the amount of listed messages'
complete -c $command \
-s n \
-d 'Show the phone numbers of listed messages'
complete -c $command -s n -d 'Show the phone numbers of listed messages'
complete -c $command \
complete -c $command -s o -x \
-a '0\tdefault' \
-s o \
-d 'Start listing calls with the specificed one' \
-x
-d 'Start listing calls with the specificed one'
complete -c $command \
complete -c $command -s t -x \
-a 'inbox\tdefault all sent draft outbox' \
-s t \
-d 'Filter listed messages by the type' \
-x
-d 'Filter listed messages by the type'

View file

@ -1,18 +1,11 @@
set command termux-sms-list
set -l command termux-sms-list
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s n -x \
-a '(__fish_complete_list , __fish_termux_api__complete_phone_numbers)' \
-s n \
-d 'Specify the recipient numbers of a message' \
-x
-d 'Specify the recipient numbers of a message'
complete -c $command \
-s s \
-d 'Specify the sim slot to use for a message' \
-x
complete -c $command -s s -x -d 'Specify the sim slot to use for a message'

View file

@ -1,10 +1,7 @@
set command termux-telephony-call
set -l command termux-telephony-call
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-a '(__fish_termux_api__complete_phone_numbers)'
complete -c $command -a '(__fish_termux_api__complete_phone_numbers)'

View file

@ -1,29 +1,19 @@
set command termux-toast
set -l command termux-toast
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s b -x \
-a '(__fish_termux_api__complete_colors)' \
-s b \
-d 'Specify the background color of a message' \
-x
-d 'Specify the background color of a message'
complete -c $command \
complete -c $command -s c -x \
-a '(__fish_termux_api__complete_colors)' \
-s c \
-d 'Specify the text color of a message' \
-x
-d 'Specify the text color of a message'
complete -c $command \
complete -c $command -s g -x \
-a 'middle\tdefault top bottom' \
-s g \
-d 'Specify the position of a message' \
-x
-d 'Specify the position of a message'
complete -c $command \
-s s \
-d 'Show a message for the short period of time'
complete -c $command -s s -d 'Show a message for the short period of time'

View file

@ -1,11 +1,7 @@
set command termux-torch
set -l command termux-torch
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-a 'on off' \
-d 'Toggle the LED torch of a device' \
complete -c $command -a 'on off' -d 'Toggle the LED torch of a device'

View file

@ -1,44 +1,19 @@
set command termux-tts-speak
set -l command termux-tts-speak
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s e -x \
-a '(__fish_termux_api__complete_tts_engines)' \
-s e \
-d 'Specify the TTS engine for a speech' \
-x
-d 'Specify the TTS engine for a speech'
complete -c $command \
-s l \
-d 'Specify the language of a speech' \
-x
complete -c $command -s l -x -d 'Specify the language of a speech'
complete -c $command -s n -x -d 'Specify the region of a speech'
complete -c $command -s v -x -d 'Specify the language variant of a speech'
complete -c $command -s p -x -d 'Specify the pitch of a speech'
complete -c $command -s r -x -d 'Specify the rate of a speech'
complete -c $command \
-s n \
-d 'Specify the region of a speech' \
-x
complete -c $command \
-s v \
-d 'Specify the language variant of a speech' \
-x
complete -c $command \
-s p \
-d 'Specify the pitch of a speech' \
-x
complete -c $command \
-s r \
-d 'Specify the rate of a speech' \
-x
complete -c $command \
complete -c $command -s s -x \
-a '(__fish_termux_api__complete_stream_ids | string replace --regex "(notification)" "\$1\tdefault")' \
-s s \
-d 'Specify the stream for a speech' \
-x
-d 'Specify the stream for a speech'

View file

@ -1,21 +1,9 @@
set command termux-usb
set -l command termux-usb
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s l \
-d 'List all devices'
complete -c $command \
-s r \
-d 'Show the permission request dialog for a device'
complete -c $command \
-s e \
-d 'execute the specified command for a device' \
-x
complete -c $command -s l -d 'List all devices'
complete -c $command -s r -d 'Show the permission request dialog for a device'
complete -c $command -s e -x -d 'Execute the specified command for a device'

View file

@ -1,17 +1,11 @@
set command termux-vibrate
set -l command termux-vibrate
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
complete -c $command -s d -x \
-a '1000\tdefault' \
-s d \
-d 'Specify the duration of a vibration' \
-x
-d 'Specify the duration of a vibration'
complete -c $command \
-s f \
-d 'Vibrate in a silent mode too'
complete -c $command -s f -d 'Vibrate in a silent mode too'

View file

@ -1,7 +1,6 @@
set command termux-volume
set -l command termux-volume
complete -c $command -f
complete -c $command \
-a '(__fish_termux_api__complete_stream_ids)' \
complete -c $command -a '(__fish_termux_api__complete_stream_ids)' \
-d 'Specify the stream for a volume'

View file

@ -1,21 +1,9 @@
set command termux-wallpaper
set -l command termux-wallpaper
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-s f \
-d 'Specify the file of a wallpaper' \
-F -r
complete -c $command \
-s u \
-d 'Specify the uRL of a wallpaper' \
-F -r
complete -c $command \
-s l \
-d 'Set a wallpaper for the lockscreen'
complete -c $command -s f -F -r -d 'Specify the file of a wallpaper'
complete -c $command -s u -F -r -d 'Specify the uRL of a wallpaper'
complete -c $command -s l -d 'Set a wallpaper for the lockscreen'

View file

@ -1,11 +1,8 @@
set command termux-wifi-enable
set -l command termux-wifi-enable
complete -c $command -f
complete -c $command \
-s h \
-d 'Show help'
complete -c $command -s h -d 'Show help'
complete -c $command \
-a 'true false' \
complete -c $command -a 'true false' \
-d 'Toggle the WiFi availability of a device'