From 6405c6bb6f2d013e684eef66f94d7f1c3542c303 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 4 Mar 2016 09:38:11 -0400 Subject: [PATCH] Implement device reboot command Fixes: https://github.com/resin-io/resin-cli/issues/319 --- build/actions/device.js | 12 ++++++++++++ build/app.js | 2 ++ doc/cli.markdown | 9 +++++++++ lib/actions/device.coffee | 15 +++++++++++++++ lib/app.coffee | 1 + package.json | 2 +- 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/build/actions/device.js b/build/actions/device.js index 615af231..a5f6187f 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -123,6 +123,18 @@ limitations under the License. } }; + exports.reboot = { + signature: 'device reboot ', + description: 'restart a device', + help: 'Use this command to remotely reboot a device\n\nExamples:\n\n $ resin device reboot 23c73a1', + permission: 'user', + action: function(params, options, done) { + var resin; + resin = require('resin-sdk'); + return resin.models.device.reboot(params.uuid).nodeify(done); + } + }; + exports.rename = { signature: 'device rename [newName]', description: 'rename a resin device', diff --git a/build/app.js b/build/app.js index 92b0bea1..5b38e80a 100644 --- a/build/app.js +++ b/build/app.js @@ -87,6 +87,8 @@ limitations under the License. capitano.command(actions.device.identify); + capitano.command(actions.device.reboot); + capitano.command(actions.device.register); capitano.command(actions.device.move); diff --git a/doc/cli.markdown b/doc/cli.markdown index cf68ffa7..3c1db2ad 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -36,6 +36,7 @@ Now you have access to all the commands referenced below. - [device register <application>](#device-register-60-application-62-) - [device rm <uuid>](#device-rm-60-uuid-62-) - [device identify <uuid>](#device-identify-60-uuid-62-) + - [device reboot <uuid>](#device-reboot-60-uuid-62-) - [device rename <uuid> [newName]](#device-rename-60-uuid-62-newname-) - [device move <uuid>](#device-move-60-uuid-62-) - [device init](#device-init) @@ -308,6 +309,14 @@ Examples: $ resin device identify 23c73a1 +## device reboot <uuid> + +Use this command to remotely reboot a device + +Examples: + + $ resin device reboot 23c73a1 + ## device rename <uuid> [newName] Use this command to rename a device. diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index 67e3d32b..d11032f5 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -171,6 +171,21 @@ exports.identify = resin = require('resin-sdk') resin.models.device.identify(params.uuid).nodeify(done) +exports.reboot = + signature: 'device reboot ' + description: 'restart a device' + help: ''' + Use this command to remotely reboot a device + + Examples: + + $ resin device reboot 23c73a1 + ''' + permission: 'user' + action: (params, options, done) -> + resin = require('resin-sdk') + resin.models.device.reboot(params.uuid).nodeify(done) + exports.rename = signature: 'device rename [newName]' description: 'rename a resin device' diff --git a/lib/app.coffee b/lib/app.coffee index 6a05102a..9866b664 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -69,6 +69,7 @@ capitano.command(actions.device.rename) capitano.command(actions.device.init) capitano.command(actions.device.remove) capitano.command(actions.device.identify) +capitano.command(actions.device.reboot) capitano.command(actions.device.register) capitano.command(actions.device.move) capitano.command(actions.device.info) diff --git a/package.json b/package.json index c77a8e5a..826510a0 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "resin-device-init": "^2.0.0", "resin-image-manager": "^4.0.0", "resin-pine": "^1.3.0", - "resin-sdk": "^5.1.0", + "resin-sdk": "^5.2.0", "resin-settings-client": "^3.1.0", "resin-vcs": "^2.0.0", "rimraf": "^2.4.3",