Skip to content

Commit d2cd5be

Browse files
Fatme HavaluovaFatme Havaluova
authored andcommitted
List devices command
1 parent e40a375 commit d2cd5be

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

lib/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $injector.requireCommand("build", "./commands/build");
2727
$injector.requireCommand("deploy", "./commands/deploy");
2828
$injector.requireCommand("dev-post-install", "./commands/post-install");
2929
$injector.requireCommand("emulate", "./commands/emulate");
30+
$injector.requireCommand("list-devices", "./commands/list-devices");
3031

3132
$injector.require("npm", "./node-package-manager");
3233
$injector.require("config", "./config");

lib/commands/list-devices.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///<reference path="../.d.ts"/>
2+
import helpers = require("./../common/helpers");
3+
import util = require("util")
4+
5+
export class ListDevicesCommand implements ICommand {
6+
constructor(private $devicesServices: Mobile.IDevicesServices,
7+
private $logger: ILogger) { }
8+
9+
execute(args: string[]): IFuture<void> {
10+
return (() => {
11+
var index = 1;
12+
this.$devicesServices.initialize(args[0], null, {skipInferPlatform: true}).wait();
13+
14+
var action = (device: Mobile.IDevice) => {
15+
return (() => { this.$logger.out("#%d: '%s'", (index++).toString(), device.getDisplayName(), device.getPlatform(), device.getIdentifier()); }).future<void>()();
16+
};
17+
this.$devicesServices.execute(action, undefined, {allowNoDevices: true}).wait();
18+
}).future<void>()();
19+
}
20+
}
21+
$injector.registerCommand("list-devices", ListDevicesCommand);

resources/help.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ General commands:
1616
build Builds the project for the selected target platform and produces an application package.
1717
deploy Deploys the project to a connected device.
1818
run Runs your project on a connected device. This is shorthand for prepare, build, and deploy.
19+
list-devices Lists all recognized connected devices.
1920
feature-usage-tracking Configures anonymous feature usage tracking.
2021

2122
General options:
@@ -175,6 +176,17 @@ Runs your project on a connected device. This is shorthand for prepare, build, a
175176

176177
Usage:
177178
$ tns emulate [<platform>]
179+
180+
--[/]--
181+
182+
--[list-devices]--
183+
184+
Lists all recognized connected devices with serial number and index, grouped by platform. In this version of the Telerik NativeScript CLI,
185+
you can connect only iOS and Android devices.
186+
187+
If a connected Android device is not shown in the list, make sure that you have installed the required Android USB drivers on your system
188+
and that USB debugging is enabled on the device.
189+
178190
--[/]--
179191

180192
--[feature-usage-tracking]--

resources/platform-tools/android/darwin/adb

100644100755
File mode changed.

0 commit comments

Comments
 (0)