From f52dd2976f6c6f8f3fbe8d28dda819f2851e7898 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Sun, 15 Nov 2015 22:08:02 -0400 Subject: [PATCH] Implement settings command This command allows the user to list all detected settings. --- build/actions/index.js | 1 + build/actions/settings.js | 17 +++++++++++++++++ build/app.js | 2 ++ capitanodoc.json | 6 ++++++ doc/cli.markdown | 14 ++++++++++++++ lib/actions/index.coffee | 1 + lib/actions/settings.coffee | 18 ++++++++++++++++++ lib/app.coffee | 3 +++ package.json | 2 +- 9 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 build/actions/settings.js create mode 100644 lib/actions/settings.coffee diff --git a/build/actions/index.js b/build/actions/index.js index abedba94..4ef549b3 100644 --- a/build/actions/index.js +++ b/build/actions/index.js @@ -11,6 +11,7 @@ notes: require('./notes'), help: require('./help'), os: require('./os'), + settings: require('./settings'), config: require('./config') }; diff --git a/build/actions/settings.js b/build/actions/settings.js new file mode 100644 index 00000000..4efffec5 --- /dev/null +++ b/build/actions/settings.js @@ -0,0 +1,17 @@ +(function() { + var prettyjson, resin; + + resin = require('resin-sdk'); + + prettyjson = require('prettyjson'); + + exports.list = { + signature: 'settings', + description: 'print current settings', + help: 'Use this command to display detected settings\n\nExamples:\n\n $ resin settings', + action: function(params, options, done) { + return resin.settings.getAll().then(prettyjson.render).then(console.log).nodeify(done); + } + }; + +}).call(this); diff --git a/build/app.js b/build/app.js index f133dac5..2e22359c 100644 --- a/build/app.js +++ b/build/app.js @@ -104,6 +104,8 @@ capitano.command(actions.config.reconfigure); + capitano.command(actions.settings.list); + capitano.command(actions.logs); update.notify(); diff --git a/capitanodoc.json b/capitanodoc.json index 5a7c758c..e43dafc0 100644 --- a/capitanodoc.json +++ b/capitanodoc.json @@ -68,6 +68,12 @@ "lib/actions/config.coffee" ] }, + { + "title": "Settings", + "files": [ + "lib/actions/settings.coffee" + ] + }, { "title": "Wizard", "files": [ diff --git a/doc/cli.markdown b/doc/cli.markdown index 9408ccc9..015aa41c 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -82,6 +82,10 @@ Now you have access to all the commands referenced below. - [config write <key> <value>](#config-write-60-key-62-60-value-62-) - [config reconfigure](#config-reconfigure) +- Settings + + - [settings](#settings) + - Wizard - [quickstart [name]](#quickstart-name-) @@ -670,6 +674,16 @@ drive show advanced commands +# Settings + +## settings + +Use this command to display detected settings + +Examples: + + $ resin settings + # Wizard ## quickstart [name] diff --git a/lib/actions/index.coffee b/lib/actions/index.coffee index ad8cbde2..20268250 100644 --- a/lib/actions/index.coffee +++ b/lib/actions/index.coffee @@ -10,4 +10,5 @@ module.exports = notes: require('./notes') help: require('./help') os: require('./os') + settings: require('./settings') config: require('./config') diff --git a/lib/actions/settings.coffee b/lib/actions/settings.coffee new file mode 100644 index 00000000..792c1d82 --- /dev/null +++ b/lib/actions/settings.coffee @@ -0,0 +1,18 @@ +resin = require('resin-sdk') +prettyjson = require('prettyjson') + +exports.list = + signature: 'settings' + description: 'print current settings' + help: ''' + Use this command to display detected settings + + Examples: + + $ resin settings + ''' + action: (params, options, done) -> + resin.settings.getAll() + .then(prettyjson.render) + .then(console.log) + .nodeify(done) diff --git a/lib/app.coffee b/lib/app.coffee index caf101a3..dae87a6e 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -75,6 +75,9 @@ capitano.command(actions.config.read) capitano.command(actions.config.write) capitano.command(actions.config.reconfigure) +# ---------- Settings Module ---------- +capitano.command(actions.settings.list) + # ---------- Logs Module ---------- capitano.command(actions.logs) diff --git a/package.json b/package.json index 6e39c57d..b4d8b47d 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "resin-image": "^1.1.4", "resin-image-manager": "^3.2.2", "resin-pine": "^1.3.0", - "resin-sdk": "^4.1.1", + "resin-sdk": "^4.1.2", "resin-settings-client": "^3.1.0", "resin-vcs": "^2.0.0", "rimraf": "^2.4.3",