From b2425d2c0e3d7f346e7f8b091bb018faf82a8354 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 15 Oct 2015 08:48:34 -0400 Subject: [PATCH] Take device type as an option in os initialize --- build/actions/device.js | 2 +- build/actions/os.js | 14 ++++++++++---- doc/cli.markdown | 22 +++++++++++++++++++--- lib/actions/device.coffee | 2 +- lib/actions/os.coffee | 15 +++++++++++---- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/build/actions/device.js b/build/actions/device.js index 34b8d79f..f0446bf6 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -154,7 +154,7 @@ return Promise.using(download(), function(temporalPath) { return capitano.runAsync("device register " + application.app_name).then(resin.models.device.get).tap(function(device) { return capitano.runAsync("os configure " + temporalPath + " " + device.uuid).then(function() { - return helpers.sudo(['os', 'initialize', temporalPath, application.device_type]); + return helpers.sudo(['os', 'initialize', temporalPath, '--type', application.device_type]); }); }); }).then(function(device) { diff --git a/build/actions/os.js b/build/actions/os.js index 9f19ccbb..ad3eb410 100644 --- a/build/actions/os.js +++ b/build/actions/os.js @@ -100,12 +100,18 @@ }; exports.initialize = { - signature: 'os initialize ', + signature: 'os initialize ', description: 'initialize an os image', - help: 'Use this command to initialize a previously configured operating system image.\n\nExamples:\n\n $ resin os initialize ../path/rpi.img \'raspberry-pi\'', + help: 'Use this command to initialize a previously configured operating system image.\n\nExamples:\n\n $ resin os initialize ../path/rpi.img --type \'raspberry-pi\'', permission: 'user', options: [ commandOptions.yes, { + signature: 'type', + description: 'device type', + parameter: 'type', + alias: 't', + required: 'You have to specify a device type' + }, { signature: 'drive', description: 'drive', parameter: 'drive', @@ -115,7 +121,7 @@ root: true, action: function(params, options, done) { console.info('Initializing device'); - return resin.models.device.getManifestBySlug(params.type).then(function(manifest) { + return resin.models.device.getManifestBySlug(options.type).then(function(manifest) { var ref; return (ref = manifest.initialization) != null ? ref.options : void 0; }).then(function(questions) { @@ -132,7 +138,7 @@ message = "This will erase " + answers.drive + ". Are you sure?"; return patterns.confirm(options.yes, message)["return"](answers.drive).then(umount.umountAsync); }).tap(function(answers) { - return init.initialize(params.image, params.type, answers).then(stepHandler); + return init.initialize(params.image, options.type, answers).then(stepHandler); }).then(function(answers) { if (answers.drive == null) { return; diff --git a/doc/cli.markdown b/doc/cli.markdown index 66bf9d16..126e1e26 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -74,7 +74,7 @@ Now you have access to all the commands referenced below. - [os download <type>](#os-download-60-type-62-) - [os configure <image> <uuid>](#os-configure-60-image-62-60-uuid-62-) - - [os initialize <image> <type>](#os-initialize-60-image-62-60-type-62-) + - [os initialize <image>](#os-initialize-60-image-62-) - Wizard @@ -426,6 +426,12 @@ Examples: $ resin help apps $ resin help os download +### Options + +#### --verbose, -v + +show additional commands + # Information ## version @@ -550,13 +556,23 @@ Examples: $ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 -## os initialize <image> <type> +## os initialize <image> Use this command to initialize a previously configured operating system image. Examples: - $ resin os initialize ../path/rpi.img 'raspberry-pi' + $ resin os initialize ../path/rpi.img --type 'raspberry-pi' + +### Options + +#### --yes, -y + +confirm non interactively + +#### --type, -t <type> + +device type # Wizard diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index f1b50411..1a55a002 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -211,7 +211,7 @@ exports.init = .then(resin.models.device.get) .tap (device) -> capitano.runAsync("os configure #{temporalPath} #{device.uuid}").then -> - helpers.sudo([ 'os', 'initialize', temporalPath, application.device_type ]) + helpers.sudo([ 'os', 'initialize', temporalPath, '--type', application.device_type ]) .then (device) -> console.log('Done') return device.uuid diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index 42632733..be9fe807 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -96,18 +96,25 @@ exports.configure = .nodeify(done) exports.initialize = - signature: 'os initialize ' + signature: 'os initialize ' description: 'initialize an os image' help: ''' Use this command to initialize a previously configured operating system image. Examples: - $ resin os initialize ../path/rpi.img 'raspberry-pi' + $ resin os initialize ../path/rpi.img --type 'raspberry-pi' ''' permission: 'user' options: [ commandOptions.yes + { + signature: 'type' + description: 'device type' + parameter: 'type' + alias: 't' + required: 'You have to specify a device type' + } { signature: 'drive' description: 'drive' @@ -118,7 +125,7 @@ exports.initialize = root: true action: (params, options, done) -> console.info('Initializing device') - resin.models.device.getManifestBySlug(params.type) + resin.models.device.getManifestBySlug(options.type) .then (manifest) -> return manifest.initialization?.options .then (questions) -> @@ -132,7 +139,7 @@ exports.initialize = .return(answers.drive) .then(umount.umountAsync) .tap (answers) -> - return init.initialize(params.image, params.type, answers).then(stepHandler) + return init.initialize(params.image, options.type, answers).then(stepHandler) .then (answers) -> return if not answers.drive? umount.umountAsync(answers.drive).tap ->