Allow advanced option in device init

This option is inherited to `os configure`.
This commit is contained in:
Juan Cruz Viotti 2015-10-20 09:16:56 -04:00
parent ff81c1e514
commit f2507daa09
3 changed files with 28 additions and 3 deletions

View File

@ -143,7 +143,14 @@
signature: 'device init', signature: 'device init',
description: 'initialise a device with resin os', description: 'initialise a device with resin os',
help: 'Use this command to download the OS image of a certain application and write it to an SD Card.\n\nNotice this command may ask for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device init\n $ resin device init --application MyApp', help: 'Use this command to download the OS image of a certain application and write it to an SD Card.\n\nNotice this command may ask for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device init\n $ resin device init --application MyApp',
options: [commandOptions.optionalApplication, commandOptions.yes], options: [
commandOptions.optionalApplication, commandOptions.yes, {
signature: 'advanced',
description: 'enable advanced configuration',
boolean: true,
alias: 'v'
}
],
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
@ -163,7 +170,12 @@
}; };
return Promise.using(download(), function(temporalPath) { 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("device register " + application.app_name).then(resin.models.device.get).tap(function(device) {
return capitano.runAsync("os configure " + temporalPath + " " + device.uuid).then(function() { var configure;
configure = "os configure " + temporalPath + " " + device.uuid;
if (options.advanced) {
configure += ' --advanced';
}
return capitano.runAsync(configure).then(function() {
return helpers.sudo(['os', 'initialize', temporalPath, '--type', application.device_type]); return helpers.sudo(['os', 'initialize', temporalPath, '--type', application.device_type]);
}); });
}); });

View File

@ -317,6 +317,10 @@ application name
confirm non interactively confirm non interactively
#### --advanced, -v
enable advanced configuration
# Environment Variables # Environment Variables
## envs ## envs

View File

@ -198,6 +198,12 @@ exports.init =
options: [ options: [
commandOptions.optionalApplication commandOptions.optionalApplication
commandOptions.yes commandOptions.yes
{
signature: 'advanced'
description: 'enable advanced configuration'
boolean: true
alias: 'v'
}
] ]
permission: 'user' permission: 'user'
primary: true primary: true
@ -218,7 +224,10 @@ exports.init =
capitano.runAsync("device register #{application.app_name}") capitano.runAsync("device register #{application.app_name}")
.then(resin.models.device.get) .then(resin.models.device.get)
.tap (device) -> .tap (device) ->
capitano.runAsync("os configure #{temporalPath} #{device.uuid}").then -> configure = "os configure #{temporalPath} #{device.uuid}"
configure += ' --advanced' if options.advanced
capitano.runAsync(configure).then ->
helpers.sudo([ 'os', 'initialize', temporalPath, '--type', application.device_type ]) helpers.sudo([ 'os', 'initialize', temporalPath, '--type', application.device_type ])
.then (device) -> .then (device) ->
console.log('Done') console.log('Done')