diff --git a/build/actions/device.js b/build/actions/device.js index f0446bf6..6e33be3a 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -70,9 +70,19 @@ description: 'register a device', help: 'Use this command to register a device to an application.\n\nExamples:\n\n $ resin device register MyApp', permission: 'user', + options: [ + { + signature: 'uuid', + description: 'custom uuid', + parameter: 'uuid', + alias: 'u' + } + ], action: function(params, options, done) { return resin.models.application.get(params.application).then(function(application) { - return resin.models.device.generateUUID().then(function(uuid) { + return Promise["try"](function() { + return options.uuid || resin.models.device.generateUUID(); + }).then(function(uuid) { console.info("Registering to " + application.app_name + ": " + uuid); return resin.models.device.register(application.app_name, uuid); }); diff --git a/doc/cli.markdown b/doc/cli.markdown index 126e1e26..f5ba48e0 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -250,6 +250,12 @@ Examples: $ resin device register MyApp +### Options + +#### --uuid, -u <uuid> + +custom uuid + ## device rm <uuid> Use this command to remove a device from resin.io. diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index 1a55a002..aa07b211 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -98,10 +98,18 @@ exports.register = $ resin device register MyApp ''' permission: 'user' + options: [ + signature: 'uuid' + description: 'custom uuid' + parameter: 'uuid' + alias: 'u' + ] action: (params, options, done) -> resin.models.application.get(params.application).then (application) -> - resin.models.device.generateUUID().then (uuid) -> + Promise.try -> + return options.uuid or resin.models.device.generateUUID() + .then (uuid) -> console.info("Registering to #{application.app_name}: #{uuid}") return resin.models.device.register(application.app_name, uuid) .get('uuid')