apps/cli: Minor cleanup of mote-exec.js
[remote.git] / apps / cli / src / main / javascript / mote-exec.js
blobb9e5fb8c1a007687848fca7e325263eef5e94547
1 /*
2 * Script that mimics the behavior of the mote-exec subcommand.
3 */
5 var accessDone = new java.lang.Runnable() {
7 run: function()
9 println("Access granted");
10 mote.control(controlDone);
15 var controlDone = new java.lang.Runnable() {
17 run: function()
19 println("Control granted");
20 mote.console();
21 println("Starting");
22 mote.program(args[1], programDone);
27 var consoleDone = new java.lang.Runnable() {
29 run: function()
31 println("Console setup");
36 var programDone = new java.lang.Runnable() {
38 run: function()
40 println("Starting the program");
41 mote.start(commandDone);
46 var commandDone = new java.lang.Runnable() {
48 run: function()
50 println("Done");
55 if (args[0] == undefined)
56 command.die("Mote ID required as the first argument");
57 if (args[1] == undefined)
58 command.die("Mote program request as the second argument");
60 println("Using mote " + args[0]);
61 mote = command.getMote(args[0]);
63 println("Get access");
64 mote.access(accessDone);