Skip to content

Commit f1b0432

Browse files
authored
feat: add adb&fastboot completions (#834)
Although all correct commands have been added where possible, some instructions may be missing
1 parent afde259 commit f1b0432

File tree

4 files changed

+516
-0
lines changed

4 files changed

+516
-0
lines changed
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
def "nu-complete adb one-device-args" [] {
2+
[SERIAL USB]
3+
}
4+
5+
def "nu-complete adb compression-algorithm" [] {
6+
[any none brotli lz4 zstd]
7+
}
8+
9+
def "nu-complete adb sync-partations" [] {
10+
[all data odm oem product system system_ext vendor]
11+
}
12+
13+
def "nu-complete adb wait-for-state" [] {
14+
[-device -recovery -rescue -sideload -bootloader -disconnect]
15+
}
16+
17+
def "nu-complete adb wait-for-transport" [] {
18+
[-usb -local -any]
19+
}
20+
21+
def "nu-complete adb reboot-type" [] {
22+
[
23+
bootloader
24+
recovery
25+
edl
26+
sideload # Reboots into recovery and automatically starts sideload mode.
27+
sideload-auto-reboot
28+
" "
29+
]
30+
}
31+
32+
export extern "adb" [
33+
-a # listen on all network interfaces, not just localhost
34+
-d # use USB device (error if multiple devices connected)
35+
-e # use TCP/IP device (error if multiple TCP/IP devices available)
36+
-s: string # use device with given serial (overrides $ANDROID_SERIAL)
37+
-t: string # use device with given transport id
38+
-H: string # name of adb server host [default=localhost]
39+
-P: int # port of adb server [default=5037]
40+
-L: string # listen on given socket for adb server [default=tcp:localhost:5037]
41+
42+
--exit-on-write-error # exit if stdout is closed
43+
]
44+
45+
# Show this help message.
46+
export extern "adb help" []
47+
48+
# Show version number.
49+
export extern "adb version" []
50+
51+
# Connect to a device via TCP/IP [default PORT=5555].
52+
export extern "adb connect" [
53+
host_port: string # Connect to a device via TCP/IP [default PORT=5555].
54+
]
55+
56+
# Disconnect from given TCP/IP device [default PORT=5555], or all.
57+
export extern "adb disconnect" [
58+
host_port?: string # Disconnect device via TCP/IP [default PORT=5555] (disconnec all if no ip given).
59+
]
60+
61+
# Pair with a device for secure TCP/IP communication.
62+
export extern "adb pair" [
63+
host_port: string # Connect to a device via TCP/IP [default PORT=5555].
64+
PAIRING_CODE: string
65+
]
66+
67+
export extern "adb forward" [
68+
--list # List all forward socket connections.
69+
--no-rebind
70+
LOCAL_REMOTE: string # Forward socket connection using one of the followings. tcp:PORT (local may be “tcp:0” to pick any open port. localreserved:UNIX_DOMAIN_SOCKET_NAME. localfilesystem:UNIX_DOMAIN_SOCKET_NAME. jdwp:PROCESS PID (remote only). vsock:CID:PORT (remote only). acceptfd:FD (listen only). dev:DEVICE_NAME. dev-raw:DEVICE_NAME. (open device in raw mode)**.
71+
--remove: string # Remove specific forward socket connection.
72+
--remove-all # Remove all forward socket connections.
73+
]
74+
75+
export extern "adb reverse" [
76+
--list # List all forward socket connections.
77+
--no-rebind
78+
LOCAL_REMOTE: string # Forward socket connection using one of the followings. tcp:PORT (local may be “tcp:0” to pick any open port. localreserved:UNIX_DOMAIN_SOCKET_NAME. localfilesystem:UNIX_DOMAIN_SOCKET_NAME. jdwp:PROCESS PID (remote only). vsock:CID:PORT (remote only). acceptfd:FD (listen only). dev:DEVICE_NAME. dev-raw:DEVICE_NAME. (open device in raw mode)**.
79+
--remove: string # Remove specific forward socket connection.
80+
--remove-all # Remove all forward socket connections.
81+
]
82+
83+
export extern "adb mdns" [
84+
check # Check if mdns discovery is available.
85+
services # List all discovered services.
86+
]
87+
88+
89+
# List connected devices.
90+
export extern "adb devices" [
91+
-l # Use long output.
92+
]
93+
94+
95+
# Push a single package to the device and install it
96+
export extern "adb install" [
97+
Package: string
98+
-r # Replace existing application.
99+
-t # Allow test packages.
100+
-d # Allow version code downgrade (debuggable packages only).
101+
-p # Partial application install (install-multiple only).
102+
-g # Grant all runtime permissions.
103+
--abi:string # Override platform's default ABI.
104+
--instant # Cause the app to be installed as an ephemeral install app.
105+
--no-streaming # Always push APK to device and invoke Package Manager as separate steps.
106+
--streaming # Force streaming APK directly into Package Manager.
107+
--fastdeploy # Use fast deploy.
108+
--no-fastdeploy # Prevent use of fast deploy.
109+
--force-agent # Force update of deployment agent when using fast deploy.
110+
--date-check-agent # Update deployment agent when local version is newer and using fast deploy.
111+
--version-check-agent # Update deployment agent when local version has different version code and using fast deploy.
112+
--local-agent # Locate agent files from local source build (instead of SDK location). See also adb shell pm help for more options.
113+
]
114+
115+
116+
117+
# Push one or more packages to the device and install them atomically
118+
export extern "adb install-multiple" [
119+
Package: string
120+
-r # Replace existing application.
121+
-t # Allow test packages.
122+
-d # Allow version code downgrade (debuggable packages only).
123+
-p # Partial application install (install-multiple only).
124+
-g # Grant all runtime permissions.
125+
--abi:string # Override platform's default ABI.
126+
--instant # Cause the app to be installed as an ephemeral install app.
127+
--no-streaming # Always push APK to device and invoke Package Manager as separate steps.
128+
--streaming # Force streaming APK directly into Package Manager.
129+
--fastdeploy # Use fast deploy.
130+
--no-fastdeploy # Prevent use of fast deploy.
131+
--force-agent # Force update of deployment agent when using fast deploy.
132+
--date-check-agent # Update deployment agent when local version is newer and using fast deploy.
133+
--version-check-agent # Update deployment agent when local version has different version code and using fast deploy.
134+
--local-agent # Locate agent files from local source build (instead of SDK location). See also adb shell pm help for more options.
135+
]
136+
137+
export extern "adb install-multi-package" [
138+
Package: string
139+
-r # Replace existing application.
140+
-t # Allow test packages.
141+
-d # Allow version code downgrade (debuggable packages only).
142+
-p # Partial application install (install-multiple only).
143+
-g # Grant all runtime permissions.
144+
--abi:string # Override platform's default ABI.
145+
--instant # Cause the app to be installed as an ephemeral install app.
146+
--no-streaming # Always push APK to device and invoke Package Manager as separate steps.
147+
--streaming # Force streaming APK directly into Package Manager.
148+
--fastdeploy # Use fast deploy.
149+
--no-fastdeploy # Prevent use of fast deploy.
150+
--force-agent # Force update of deployment agent when using fast deploy.
151+
--date-check-agent # Update deployment agent when local version is newer and using fast deploy.
152+
--version-check-agent # Update deployment agent when local version has different version code and using fast deploy.
153+
--local-agent # Locate agent files from local source build (instead of SDK location). See also adb shell pm help for more options.
154+
]
155+
156+
157+
# Remove specified application from the device
158+
export extern "adb uninstall" [
159+
APPLICATION_ID: string # Remove this APPLICATION_ID from the device.
160+
-k
161+
]
162+
163+
# Run remote shell command (interactive shell if no command given)
164+
export extern "adb shell" [
165+
-e # Choose escape character, or “none”; default ‘~’.
166+
-n # Don't read from stdin
167+
-T # Disable pty allocation.
168+
-t # Allocate a pty if on a tty (-tt force pty allocation).
169+
-x # Disable remote exit codes and stdout/stderr separation.
170+
COMMAND?:string # Run emulator console COMMAND
171+
]
172+
173+
174+
# Copy local files/directories to device.
175+
export extern "adb push" [
176+
--sync # Only push files that are newer on the host than the device.
177+
-n # Dry run, push files to device without storing to the filesystem.
178+
-z:string@"nu-complete adb compression-algorithm" # enable compression with a specified algorithm (any/none/brotli/lz4/zstd).
179+
-Z # Disable compression.
180+
181+
]
182+
183+
# Copy files/dirs from device
184+
export extern "adb pull" [
185+
-a # preserve file timestamp and mode.
186+
--sync # Only push files that are newer on the host than the device.
187+
-n # Dry run. Push files to device without storing to the filesystem.
188+
-z:string@"nu-complete adb compression-algorithm" # enable compression with a specified algorithm (any/none/brotli/lz4/zstd).
189+
-Z # Disable compression.
190+
...remote: string
191+
local: string
192+
]
193+
194+
195+
# Sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
196+
export extern "adb sync" [
197+
parations: string@"nu-complete adb sync-partations"
198+
-n # Dry run. Push files to device without storing to the filesystem.
199+
-z:string@"nu-complete adb compression-algorithm" # enable compression with a specified algorithm (any/none/brotli/lz4/zstd).
200+
-Z # Disable compression.
201+
-l # List files that would be copied, but don't copy them.
202+
]
203+
204+
# Ensure that there is a server running.
205+
export extern "adb start-server" [ # only allowed with 'start-server' or 'server nodaemon',
206+
--one-device: string@"nu-complete adb one-device-args" #server will only connect to one USB device, specified by a serial number or USB device address.
207+
]
208+
209+
# Kill the server if it is running.
210+
export extern "adb kill-server" []
211+
212+
# Close connection from host or device side to force reconnect.
213+
export extern "adb reconnect" [
214+
device?: string
215+
]
216+
217+
# Close connection from device side to force reconnect.
218+
export extern "adb reconnect device" []
219+
220+
# Reset offline/unauthorized devices to force reconnect.
221+
export extern "adb reconnect offline" []
222+
223+
# Attach a detached USB device identified by its SERIAL number.
224+
export extern "adb attach" [
225+
SERIAL: string
226+
]
227+
228+
# Detach from a USB device identified by its SERIAL to allow use by other processes.
229+
export extern "adb detach" [
230+
SERIAL: string
231+
]
232+
233+
# list features supported by adb server.
234+
export extern "adb host-features" []
235+
236+
# list features supported by both adb server and device.
237+
export extern "adb features" []
238+
239+
# Write bugreport
240+
export extern "adb bugreport" [
241+
PATH: string # PATH [default=bugreport.zip]; if PATH is a directory, the bug report is saved in that directory. devices that don't support zipped bug reports output to stdout.
242+
243+
]
244+
245+
# List pids of processes hosting a JDWP transport.
246+
export extern "adb jdwp" []
247+
248+
# Show device log (logcat --help for more).
249+
export extern "adb logcat" []
250+
251+
# Disable dm-verity checking on userdebug builds.
252+
export extern "adb disable-verity" []
253+
254+
# Re-enable dm-verity checking on userdebug builds.
255+
export extern "adb enable-verity" []
256+
257+
# Generate adb public/private key; private key stored in FILE.
258+
export extern "adb keygen" [
259+
FILE: string
260+
]
261+
262+
# Wait for device to be in a given state.
263+
export extern "adb wait-for" [
264+
STATE: string@"nu-complete adb wait-for-state"
265+
TRANSPORT: string@"nu-complete adb wait-for-transport"
266+
]
267+
268+
# Print offline | bootloader | device.
269+
export extern "adb get-state" []
270+
271+
# Print SERIAL_NUMBER.
272+
export extern "adb get-serialno" []
273+
274+
# Print DEVICE_PATH.
275+
export extern "adb get-devpath" []
276+
277+
# Remount partitions read-write.
278+
export extern "adb remount" [
279+
-R # Automatically reboot the device.
280+
]
281+
282+
# Reboot the device; defaults to booting system image but supports bootloader and recovery too.
283+
export extern "adb reboot" [
284+
type:string@"nu-complete adb reboot-type"
285+
]
286+
287+
# Sideload the given full OTA package
288+
export extern "adb sideload" [
289+
OTAPACKAGE: string
290+
]
291+
292+
# Restart adbd with root permissions.
293+
export extern "adb root" []
294+
295+
# Restart adbd without root permissions.
296+
export extern "adb unroot" []
297+
298+
# Restart adbd listening on USB.
299+
export extern "adb usb" []
300+
301+
# Restart adbd listening on TCP on PORT.
302+
export extern "adb tcpip" [
303+
PORT:string
304+
]

custom-completions/adb/readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SDK Platform Tools completions
2+
3+
A Nushell extern definition and completers for [Android Debugger Bridge `adb`](https://developer.android.com/tools/adb).
4+
5+
6+
This module provides extern definitions for almost all of the `adb` commands and their flags.
7+
8+
## Usage
9+
10+
simply import the extern definitions with
11+
12+
```nu
13+
use path/to/adb-completions.nu * # don't forget the star `*`
14+
```
15+
16+
or
17+
18+
```nu
19+
source path/to/adb-completions.nu
20+
```
21+
22+
Once imported completions will be available for commands, flags, options, and some values as well.
23+
Display the commands by entering the `→ tab` key in the command line after `adb`or any of it's command options.
24+

0 commit comments

Comments
 (0)