diff --git a/build/actions/os.js b/build/actions/os.js index ad3eb410..b317128d 100644 --- a/build/actions/os.js +++ b/build/actions/os.js @@ -91,9 +91,31 @@ description: 'configure an os image', help: 'Use this command to configure a previously download operating system image with a device.\n\nExamples:\n\n $ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9', permission: 'user', + options: [ + { + signature: 'advanced', + description: 'show advanced commands', + boolean: true, + alias: 'v' + } + ], action: function(params, options, done) { console.info('Configuring operating system image'); - return resin.models.device.get(params.uuid).get('device_type').then(resin.models.device.getManifestBySlug).get('options').then(form.run).then(function(answers) { + return resin.models.device.get(params.uuid).get('device_type').then(resin.models.device.getManifestBySlug).get('options').then(function(questions) { + var advancedGroup, override; + if (!options.advanced) { + advancedGroup = _.findWhere(questions, { + name: 'advanced', + isGroup: true + }); + if (advancedGroup != null) { + override = helpers.getGroupDefaults(advancedGroup); + } + } + return form.run(questions, { + override: override + }); + }).then(function(answers) { return init.configure(params.image, params.uuid, answers).then(stepHandler); }).nodeify(done); } diff --git a/build/utils/helpers.js b/build/utils/helpers.js index 541ff3a8..93a55f80 100644 --- a/build/utils/helpers.js +++ b/build/utils/helpers.js @@ -15,6 +15,12 @@ chalk = require('chalk'); + exports.getGroupDefaults = function(group) { + return _.chain(group).get('options').map(function(question) { + return [question.name, question["default"]]; + }).object().value(); + }; + exports.getOperatingSystem = function() { var platform; platform = os.platform(); diff --git a/doc/cli.markdown b/doc/cli.markdown index f5ba48e0..49bc26f4 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -562,6 +562,12 @@ Examples: $ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 +### Options + +#### --advanced, -v + +show advanced commands + ## os initialize <image> Use this command to initialize a previously configured operating system image. diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index be9fe807..fcabdcb8 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -84,13 +84,29 @@ exports.configure = $ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 ''' permission: 'user' + options: [ + signature: 'advanced' + description: 'show advanced commands' + boolean: true + alias: 'v' + ] action: (params, options, done) -> console.info('Configuring operating system image') resin.models.device.get(params.uuid) .get('device_type') .then(resin.models.device.getManifestBySlug) .get('options') - .then(form.run) + .then (questions) -> + + if not options.advanced + advancedGroup = _.findWhere questions, + name: 'advanced' + isGroup: true + + if advancedGroup? + override = helpers.getGroupDefaults(advancedGroup) + + return form.run(questions, { override }) .then (answers) -> init.configure(params.image, params.uuid, answers).then(stepHandler) .nodeify(done) diff --git a/lib/utils/helpers.coffee b/lib/utils/helpers.coffee index d97c7856..489feece 100644 --- a/lib/utils/helpers.coffee +++ b/lib/utils/helpers.coffee @@ -6,6 +6,14 @@ child_process = require('child_process') os = require('os') chalk = require('chalk') +exports.getGroupDefaults = (group) -> + return _.chain(group) + .get('options') + .map (question) -> + return [ question.name, question.default ] + .object() + .value() + exports.getOperatingSystem = -> platform = os.platform() platform = 'osx' if platform is 'darwin'