fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

huaji2369completions/waydroid: add completions for adb/bugreport add package name completions for app launch/remove replace all -fr with -xa9cc505d6

master
10.7 KiB156 linesraw
1function __fish_print_waydroid_container_package_name
2    set -l applist (waydroid app list 2>/dev/null | grep -E '^(Name: |packageName: )')
3    set -l name (string replace -f -r '^Name: ' '' $applist)
4    set -l packagename (string replace -f 'packageName: ' '' $applist)
5    for i in (seq (count $name))
6        echo $packagename[$i]\t$name[$i]
7    end
8end
9
10#all subcommands avaliable
11set -l commands status log init upgrade session container app prop show-full-ui first-launch shell logcat adb bugreport
12
13#help parameter can be used on any (sub)commands
14complete -f waydroid -s h -l help -d "show help message and exit"
15
16#disable file completions globally
17complete -f waydroid
18
19#main command parameter
20complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -s V -l version -d "show version number and exit"
21complete -F waydroid -n "not __fish_seen_subcommand_from $commands" -s l -l log -r -d "path to log file"
22complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -s v -l verbose -d "write even more to the logfiles"
23complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -s q -l quiet -d "do not output any log messages"
24complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -s w -l wait -d "wait for init before running"
25complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -l details-to-stdout -d "print details to stdout"
26
27#main command
28complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a status -d "quick check for the waydroid"
29complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a log -d "follow the waydroid logfile"
30complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a init -d "set up configs and install images"
31complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a upgrade -d "upgrade images"
32complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a session -d "session controller"
33complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a container -d "container controller"
34complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a app -d "applications controller"
35complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a prop -d "android properties controller"
36complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a show-full-ui -d "show android full screen in window"
37complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a first-launch -d "initialize waydroid and start it"
38complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a shell -d "run remote shell command"
39complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a logcat -d "show android logcat"
40complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a adb -d "manage adb connection"
41complete -f waydroid -n "not __fish_seen_subcommand_from $commands" -a bugreport -d "create a bugreport archive interactively"
42
43#log
44complete -f waydroid -n "__fish_seen_subcommand_from log" -s n -l lines -d "count of initial output lines"
45complete -f waydroid -n "__fish_seen_subcommand_from log" -s c -l clear -d "clear the log"
46
47#init
48complete -F waydroid -n "__fish_seen_subcommand_from init" -s i -l images_path -r -d "custom path to waydroid images"
49complete -f waydroid -n "__fish_seen_subcommand_from init" -s f -l force -d "re-initialize configs and images"
50complete -f waydroid -n "__fish_seen_subcommand_from init" -s c -l system_channel -d "custom system channel"
51complete -f waydroid -n "__fish_seen_subcommand_from init" -s v -l vendor_channel -d "custom vendor channel"
52complete -x waydroid -n "__fish_seen_subcommand_from init" -s r -l rom_type -a "lineage bliss" -d "rom type"
53complete -x waydroid -n "__fish_seen_subcommand_from init" -s s -l system_type -a "VANILLA FOSS GAPPS" -d "system type"
54complete -f waydroid -n "__fish_seen_subcommand_from init" -l client -d "run as user mode, connecting to the remote initializer service"
55
56#upgrade
57complete -f waydroid -n "__fish_seen_subcommand_from upgrade" -s o -l offline -d "just for updating configs"
58
59#session
60complete -f waydroid -n "__fish_seen_subcommand_from session; and not __fish_seen_subcommand_from start stop" -a start -d "start session"
61complete -f waydroid -n "__fish_seen_subcommand_from session; and not __fish_seen_subcommand_from start stop" -a stop -d "stop session"
62
63#container
64complete -f waydroid -n "__fish_seen_subcommand_from container; and not __fish_seen_subcommand_from start stop restart freeze unfreeze" -a start -d "start container"
65complete -f waydroid -n "__fish_seen_subcommand_from container; and not __fish_seen_subcommand_from start stop restart freeze unfreeze" -a stop -d "stop container"
66complete -f waydroid -n "__fish_seen_subcommand_from container; and not __fish_seen_subcommand_from start stop restart freeze unfreeze" -a restart -d "restart container"
67complete -f waydroid -n "__fish_seen_subcommand_from container; and not __fish_seen_subcommand_from start stop restart freeze unfreeze" -a freeze -d "freeze container"
68complete -f waydroid -n "__fish_seen_subcommand_from container; and not __fish_seen_subcommand_from start stop restart freeze unfreeze" -a unfreeze -d "unfreeze container"
69
70#app
71complete -x waydroid -n "__fish_seen_subcommand_from app; and not __fish_seen_subcommand_from install remove launch intent list" -a install -d "push a single package to the container and install it"
72complete -f waydroid -n "__fish_seen_subcommand_from app; and not __fish_seen_subcommand_from install remove launch intent list" -a remove -d "remove single app package from the container"
73complete -f waydroid -n "__fish_seen_subcommand_from app; and not __fish_seen_subcommand_from install remove launch intent list" -a launch -d "start single application"
74complete -f waydroid -n "__fish_seen_subcommand_from app; and not __fish_seen_subcommand_from install remove launch intent list" -a intent -d "start single application"
75complete -f waydroid -n "__fish_seen_subcommand_from app; and not __fish_seen_subcommand_from install remove launch intent list" -a list -d "list installed applications"
76#enable file completions on app install
77complete -F waydroid -n "__fish_seen_subcommand_from app; and __fish_seen_subcommand_from install"
78#package name completions for app launch and remove
79complete -x waydroid -n "__fish_seen_subcommand_from app; and __fish_seen_subcommand_from launch" -a "(__fish_print_waydroid_container_package_name)"
80complete -x waydroid -n "__fish_seen_subcommand_from app; and __fish_seen_subcommand_from remove" -a "(__fish_print_waydroid_container_package_name)"
81
82#prop
83complete -f waydroid -n "__fish_seen_subcommand_from prop; and not __fish_seen_subcommand_from get set" -a get -d "get value of property from container"
84complete -f waydroid -n "__fish_seen_subcommand_from prop; and not __fish_seen_subcommand_from get set" -a set -d "set value to property on container"
85
86#prop get/set - property name completions
87set -l props \
88    persist.waydroid.cursor_force_shm \
89    persist.waydroid.cursor_on_subsurface \
90    persist.waydroid.fake_touch \
91    persist.waydroid.fake_wifi \
92    persist.waydroid.height \
93    persist.waydroid.height_padding \
94    persist.waydroid.invert_colors \
95    persist.waydroid.multi_windows \
96    persist.waydroid.no_background_subsurface \
97    persist.waydroid.no_presentation \
98    persist.waydroid.reverse_scrolling \
99    persist.waydroid.suspend \
100    persist.waydroid.uevent \
101    persist.waydroid.use_subsurface \
102    persist.waydroid.width \
103    persist.waydroid.width_padding
104
105set -l prop_condition "__fish_seen_subcommand_from prop; and __fish_seen_subcommand_from get set; and not __fish_seen_subcommand_from $props"
106complete -f waydroid -n "$prop_condition" -a "persist.waydroid.height_padding" -d 0-9999
107complete -f waydroid -n "$prop_condition" -a "persist.waydroid.width_padding" -d 0-9999
108complete -f waydroid -n "$prop_condition" -a "persist.waydroid.width" -d 0-9999
109complete -f waydroid -n "$prop_condition" -a "persist.waydroid.height" -d 0-9999
110complete -f waydroid -n "$prop_condition" -a "persist.waydroid.multi_windows" -d bool
111complete -f waydroid -n "$prop_condition" -a "persist.waydroid.suspend" -d bool
112complete -f waydroid -n "$prop_condition" -a "persist.waydroid.uevent" -d bool
113complete -f waydroid -n "$prop_condition" -a "persist.waydroid.reverse_scrolling" -d bool
114complete -f waydroid -n "$prop_condition" -a "persist.waydroid.no_presentation" -d bool
115complete -f waydroid -n "$prop_condition" -a "persist.waydroid.invert_colors" -d bool
116complete -f waydroid -n "$prop_condition" -a "persist.waydroid.cursor_on_subsurface" -d bool
117complete -f waydroid -n "$prop_condition" -a "persist.waydroid.cursor_force_shm" -d bool
118complete -f waydroid -n "$prop_condition" -a "persist.waydroid.no_background_subsurface" -d bool
119complete -f waydroid -n "$prop_condition" -a "persist.waydroid.use_subsurface" -d bool
120complete -f waydroid -n "$prop_condition" -a "persist.waydroid.fake_touch" -d "list of package names"
121complete -f waydroid -n "$prop_condition" -a "persist.waydroid.fake_wifi" -d "list of package names"
122
123#prop set - boolean value completions
124set -l bool_props \
125    persist.waydroid.cursor_force_shm \
126    persist.waydroid.cursor_on_subsurface \
127    persist.waydroid.invert_colors \
128    persist.waydroid.multi_windows \
129    persist.waydroid.no_background_subsurface \
130    persist.waydroid.no_presentation \
131    persist.waydroid.reverse_scrolling \
132    persist.waydroid.suspend \
133    persist.waydroid.uevent \
134    persist.waydroid.use_subsurface
135
136set -l prop_condition "__fish_seen_subcommand_from prop; and __fish_seen_subcommand_from set; and __fish_seen_subcommand_from $bool_props; and not __fish_seen_subcommand_from true false"
137complete -f waydroid -n "$prop_condition" -a "true false"
138
139#shell
140complete -x waydroid -n "__fish_seen_subcommand_from shell" -s u -l uid -d "the UID to run as"
141complete -x waydroid -n "__fish_seen_subcommand_from shell" -s g -l gid -d "the GID to run as"
142complete -x waydroid -n "__fish_seen_subcommand_from shell" -s s -l context -d "transition to the specified SELinux or AppArmor security context"
143complete -f waydroid -n "__fish_seen_subcommand_from shell" -s L -l nolsm -d "Don't perform security domain transition related to mandatory access control"
144complete -f waydroid -n "__fish_seen_subcommand_from shell" -s C -l allcaps -d "Don't drop capabilities"
145complete -f waydroid -n "__fish_seen_subcommand_from shell" -s G -l nocgroup -d "Don't switch to the container cgroup"
146
147#adb
148complete -f waydroid -n "__fish_seen_subcommand_from adb" -a connect -d "connect adb to the Android container"
149complete -f waydroid -n "__fish_seen_subcommand_from adb" -a disconnect -d "disconnect adb from the Android container"
150
151#below subcommands don't have any parameter or subcommand avaliable
152#status
153#show-full-ui
154#first-launch
155#logcat
156#bugreport