-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resolve): add 'madb resolve' command
This command prints out the device serials from the given nicknames or other device specifiers. This would make it easier to use the device nicknames defined by madb in other command line tools or in shell scripts. Change-Id: I7fcb92e5c017000a9c7bb1fd08895f7fc9aa268d Closes: #10
- Loading branch information
YoungSeok Yoon
committed
Jun 23, 2016
1 parent
d9365a3
commit 5110ef4
Showing
4 changed files
with
99 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2016 The Vanadium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"v.io/x/lib/cmdline" | ||
) | ||
|
||
var cmdMadbResolve = &cmdline.Command{ | ||
Runner: subCommandRunnerWithFilepath{runMadbResolve, getDefaultConfigFilePath}, | ||
Name: "resolve", | ||
DontInheritFlags: true, | ||
Short: "Resolve device specifiers into device serials", | ||
Long: ` | ||
Resolves the provided device specifiers and prints out their device serials, | ||
each in a separate line. This command only displays the unique serials of the | ||
devices that are currently available. | ||
This command can be useful when you want to use the device nicknames and groups | ||
defined by madb in other command line tools. For example, to run a flutter app | ||
on "MyTablet" device, you can use the following command (in Bash): | ||
flutter run --device $(madb resolve MyTablet) | ||
`, | ||
ArgsName: "<specifier1> [<specifier2> ...]", | ||
ArgsLong: ` | ||
<specifier> can be anything that is accepted in the '-n' flag (see 'madb help'). | ||
It can be a device serial, qualifier, index, nickname, or a device group name. | ||
`, | ||
} | ||
|
||
func runMadbResolve(env *cmdline.Env, args []string, filename string) error { | ||
cfg, err := readConfig(filename) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
devices, err := getDevices(cfg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
filtered, err := filterSpecifiedDevices(devices, cfg, false, false, args) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, d := range filtered { | ||
fmt.Println(d.Serial) | ||
} | ||
|
||
return nil | ||
} |