Skip to content

Commit

Permalink
cli: add --list-devices flag to list detected devices (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
elimisteve authored Sep 20, 2023
1 parent ccb906d commit f2f7c47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/cli.v
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub fn args_to_options(arguments []string, defaults Options) !(Options, &flag.Fl
list_ndks: fp.bool('list-ndks', 0, defaults.list_ndks, 'List available NDK versions')
list_apis: fp.bool('list-apis', 0, defaults.list_apis, 'List available API levels')
list_build_tools: fp.bool('list-build-tools', 0, defaults.list_build_tools, 'List available Build-tools versions')
list_devices: fp.bool('list-devices', 0, defaults.list_devices, 'List available device IDs (including running emulators)')
//
screenshot: fp.string('screenshot', 0, '', 'Take a screenshot on a device and save it to /path/to/file.png or /path/to/directory')
screenshot_delay: fp.float('screenshot-delay', 0, 0.0, 'Wait for this amount of seconds before taking screenshot')
Expand Down
1 change: 1 addition & 0 deletions cli/options.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub:
list_ndks bool
list_apis bool
list_build_tools bool
list_devices bool
// screenshot functionality
screenshot string // /path/to/screenshot.png
screenshot_delay f64
Expand Down
11 changes: 11 additions & 0 deletions vab.v
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ fn main() {
}
exit(0)
}

if opt.list_devices {
devices := android.adb_get_device_list(opt.verbosity) or {
eprintln('Error getting device list: ${err}')
exit(1)
}
println('Device IDs:\n')
println(devices.join('\n'))
exit(0)
}

// All flags after this requires an input argument, except
// doing one-off screenshots on a device
if fp.args.len == 0 {
Expand Down

0 comments on commit f2f7c47

Please sign in to comment.