Merge pull request #240 from resin-io/jviotti/feature/device-init-advanced

Allow advanced option in device init
This commit is contained in:
Juan Cruz Viotti 2015-10-20 09:47:04 -04:00
commit aa949103f6
3 changed files with 28 additions and 3 deletions

View File

@ -143,7 +143,14 @@
signature: 'device init',
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',
options: [commandOptions.optionalApplication, commandOptions.yes],
options: [
commandOptions.optionalApplication, commandOptions.yes, {
signature: 'advanced',
description: 'enable advanced configuration',
boolean: true,
alias: 'v'
}
],
permission: 'user',
primary: true,
action: function(params, options, done) {
@ -163,7 +170,12 @@
};
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() {
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]);
});
});

View File

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

View File

@ -198,6 +198,12 @@ exports.init =
options: [
commandOptions.optionalApplication
commandOptions.yes
{
signature: 'advanced'
description: 'enable advanced configuration'
boolean: true
alias: 'v'
}
]
permission: 'user'
primary: true
@ -218,7 +224,10 @@ exports.init =
capitano.runAsync("device register #{application.app_name}")
.then(resin.models.device.get)
.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 ])
.then (device) ->
console.log('Done')