mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 06:57:48 +00:00
Merge pull request #211 from resin-io/jviotti/feature/101/help-topics
Separate general help per topic relevance
This commit is contained in:
commit
d65882639a
@ -30,6 +30,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.has(params.name).then(function(hasApplication) {
|
return resin.models.application.has(params.name).then(function(hasApplication) {
|
||||||
if (hasApplication) {
|
if (hasApplication) {
|
||||||
@ -51,6 +52,7 @@
|
|||||||
description: 'list all applications',
|
description: 'list all applications',
|
||||||
help: 'Use this command to list all your applications.\n\nNotice this command only shows the most important bits of information for each app.\nIf you want detailed information, use resin app <name> instead.\n\nExamples:\n\n $ resin apps',
|
help: 'Use this command to list all your applications.\n\nNotice this command only shows the most important bits of information for each app.\nIf you want detailed information, use resin app <name> instead.\n\nExamples:\n\n $ resin apps',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.getAll().then(function(applications) {
|
return resin.models.application.getAll().then(function(applications) {
|
||||||
return console.log(visuals.table.horizontal(applications, ['id', 'app_name', 'device_type', 'online_devices', 'devices_length']));
|
return console.log(visuals.table.horizontal(applications, ['id', 'app_name', 'device_type', 'online_devices', 'devices_length']));
|
||||||
@ -63,6 +65,7 @@
|
|||||||
description: 'list a single application',
|
description: 'list a single application',
|
||||||
help: 'Use this command to show detailed information for a single application.\n\nExamples:\n\n $ resin app MyApp',
|
help: 'Use this command to show detailed information for a single application.\n\nExamples:\n\n $ resin app MyApp',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.get(params.name).then(function(application) {
|
return resin.models.application.get(params.name).then(function(application) {
|
||||||
console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit']));
|
console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit']));
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
signature: 'login [token]',
|
signature: 'login [token]',
|
||||||
description: 'login to resin.io',
|
description: 'login to resin.io',
|
||||||
help: 'Use this command to login to your resin.io account.\n\nTo login, you need your token, which is accesible from the preferences page.\n\nExamples:\n\n $ resin login\n $ resin login "eyJ0eXAiOiJKV1Qi..."',
|
help: 'Use this command to login to your resin.io account.\n\nTo login, you need your token, which is accesible from the preferences page.\n\nExamples:\n\n $ resin login\n $ resin login "eyJ0eXAiOiJKV1Qi..."',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.settings.get('dashboardUrl').then(function(dashboardUrl) {
|
return resin.settings.get('dashboardUrl').then(function(dashboardUrl) {
|
||||||
return url.resolve(dashboardUrl, '/preferences');
|
return url.resolve(dashboardUrl, '/preferences');
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
help: 'Use this command to list all devices that belong to you.\n\nYou can filter the devices by application by using the `--application` option.\n\nExamples:\n\n $ resin devices\n $ resin devices --application MyApp\n $ resin devices --app MyApp\n $ resin devices -a MyApp',
|
help: 'Use this command to list all devices that belong to you.\n\nYou can filter the devices by application by using the `--application` option.\n\nExamples:\n\n $ resin devices\n $ resin devices --application MyApp\n $ resin devices --app MyApp\n $ resin devices -a MyApp',
|
||||||
options: [commandOptions.optionalApplication],
|
options: [commandOptions.optionalApplication],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return Promise["try"](function() {
|
return Promise["try"](function() {
|
||||||
if (options.application != null) {
|
if (options.application != null) {
|
||||||
@ -50,6 +51,7 @@
|
|||||||
description: 'list a single device',
|
description: 'list a single device',
|
||||||
help: 'Use this command to show information about a single device.\n\nExamples:\n\n $ resin device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9',
|
help: 'Use this command to show information about a single device.\n\nExamples:\n\n $ resin device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.device.get(params.uuid).then(function(device) {
|
return resin.models.device.get(params.uuid).then(function(device) {
|
||||||
if (device.last_seen == null) {
|
if (device.last_seen == null) {
|
||||||
@ -133,6 +135,7 @@
|
|||||||
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],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return Promise["try"](function() {
|
return Promise["try"](function() {
|
||||||
if (options.application != null) {
|
if (options.application != null) {
|
||||||
|
@ -36,13 +36,31 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
general = function(params, options, done) {
|
general = function(params, options, done) {
|
||||||
var commands;
|
var commands, groupedCommands;
|
||||||
console.log('Usage: resin [COMMAND] [OPTIONS]\n');
|
console.log('Usage: resin [COMMAND] [OPTIONS]\n');
|
||||||
console.log('Commands:\n');
|
console.log('Primary commands:\n');
|
||||||
commands = _.reject(capitano.state.commands, function(command) {
|
commands = _.reject(capitano.state.commands, function(command) {
|
||||||
return command.isWildcard();
|
return command.isWildcard();
|
||||||
});
|
});
|
||||||
print(parse(commands));
|
groupedCommands = _.groupBy(commands, function(command) {
|
||||||
|
if (command.plugin) {
|
||||||
|
return 'plugins';
|
||||||
|
} else if (command.primary) {
|
||||||
|
return 'primary';
|
||||||
|
}
|
||||||
|
return 'secondary';
|
||||||
|
});
|
||||||
|
print(parse(groupedCommands.primary));
|
||||||
|
if (options.verbose) {
|
||||||
|
if (!_.isEmpty(groupedCommands.plugins)) {
|
||||||
|
console.log('\nInstalled plugins:\n');
|
||||||
|
print(parse(groupedCommands.plugins));
|
||||||
|
}
|
||||||
|
console.log('\nAdditional commands:\n');
|
||||||
|
print(parse(groupedCommands.secondary));
|
||||||
|
} else {
|
||||||
|
console.log('\nRun `resin help --verbose` to list additional commands');
|
||||||
|
}
|
||||||
if (!_.isEmpty(capitano.state.globalOptions)) {
|
if (!_.isEmpty(capitano.state.globalOptions)) {
|
||||||
console.log('\nGlobal Options:\n');
|
console.log('\nGlobal Options:\n');
|
||||||
print(parse(capitano.state.globalOptions));
|
print(parse(capitano.state.globalOptions));
|
||||||
@ -76,6 +94,15 @@
|
|||||||
signature: 'help [command...]',
|
signature: 'help [command...]',
|
||||||
description: 'show help',
|
description: 'show help',
|
||||||
help: 'Get detailed help for an specific command.\n\nExamples:\n\n $ resin help apps\n $ resin help os download',
|
help: 'Get detailed help for an specific command.\n\nExamples:\n\n $ resin help apps\n $ resin help os download',
|
||||||
|
primary: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
signature: 'verbose',
|
||||||
|
description: 'show additional commands',
|
||||||
|
boolean: true,
|
||||||
|
alias: 'v'
|
||||||
|
}
|
||||||
|
],
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
if (params.command != null) {
|
if (params.command != null) {
|
||||||
return command(params, options, done);
|
return command(params, options, done);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var promise;
|
var promise;
|
||||||
promise = resin.logs.history(params.uuid).each(function(line) {
|
promise = resin.logs.history(params.uuid).each(function(line) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
description: 'getting started with resin.io',
|
description: 'getting started with resin.io',
|
||||||
help: 'Use this command to run a friendly wizard to get started with resin.io.\n\nThe wizard will guide you through:\n\n - Create an application.\n - Initialise an SDCard with the resin.io operating system.\n - Associate an existing project directory with your resin.io application.\n - Push your project to your devices.\n\nExamples:\n\n $ sudo resin quickstart\n $ sudo resin quickstart MyApp',
|
help: 'Use this command to run a friendly wizard to get started with resin.io.\n\nThe wizard will guide you through:\n\n - Create an application.\n - Initialise an SDCard with the resin.io operating system.\n - Associate an existing project directory with your resin.io application.\n - Push your project to your devices.\n\nExamples:\n\n $ sudo resin quickstart\n $ sudo resin quickstart MyApp',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return Promise["try"](function() {
|
return Promise["try"](function() {
|
||||||
if (params.name != null) {
|
if (params.name != null) {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
return nplugm.list(regex).map(function(plugin) {
|
return nplugm.list(regex).map(function(plugin) {
|
||||||
var command;
|
var command;
|
||||||
command = require(plugin);
|
command = require(plugin);
|
||||||
|
command.plugin = true;
|
||||||
if (!_.isArray(command)) {
|
if (!_.isArray(command)) {
|
||||||
return capitano.command(command);
|
return capitano.command(command);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ exports.create =
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
|
|
||||||
# Validate the the application name is available
|
# Validate the the application name is available
|
||||||
@ -64,6 +65,7 @@ exports.list =
|
|||||||
$ resin apps
|
$ resin apps
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.application.getAll().then (applications) ->
|
resin.models.application.getAll().then (applications) ->
|
||||||
console.log visuals.table.horizontal applications, [
|
console.log visuals.table.horizontal applications, [
|
||||||
@ -86,6 +88,7 @@ exports.info =
|
|||||||
$ resin app MyApp
|
$ resin app MyApp
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.application.get(params.name).then (application) ->
|
resin.models.application.get(params.name).then (application) ->
|
||||||
console.log visuals.table.vertical application, [
|
console.log visuals.table.vertical application, [
|
||||||
|
@ -21,6 +21,7 @@ exports.login =
|
|||||||
$ resin login
|
$ resin login
|
||||||
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||||
'''
|
'''
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.settings.get('dashboardUrl').then (dashboardUrl) ->
|
resin.settings.get('dashboardUrl').then (dashboardUrl) ->
|
||||||
return url.resolve(dashboardUrl, '/preferences')
|
return url.resolve(dashboardUrl, '/preferences')
|
||||||
|
@ -30,6 +30,7 @@ exports.list =
|
|||||||
'''
|
'''
|
||||||
options: [ commandOptions.optionalApplication ]
|
options: [ commandOptions.optionalApplication ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
if options.application?
|
if options.application?
|
||||||
@ -59,6 +60,7 @@ exports.info =
|
|||||||
$ resin device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
|
$ resin device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.device.get(params.uuid).then (device) ->
|
resin.models.device.get(params.uuid).then (device) ->
|
||||||
|
|
||||||
@ -189,6 +191,7 @@ exports.init =
|
|||||||
commandOptions.yes
|
commandOptions.yes
|
||||||
]
|
]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
return options.application if options.application?
|
return options.application if options.application?
|
||||||
|
@ -30,14 +30,31 @@ print = (data) ->
|
|||||||
|
|
||||||
general = (params, options, done) ->
|
general = (params, options, done) ->
|
||||||
console.log('Usage: resin [COMMAND] [OPTIONS]\n')
|
console.log('Usage: resin [COMMAND] [OPTIONS]\n')
|
||||||
console.log('Commands:\n')
|
console.log('Primary commands:\n')
|
||||||
|
|
||||||
# We do not want the wildcard command
|
# We do not want the wildcard command
|
||||||
# to be printed in the help screen.
|
# to be printed in the help screen.
|
||||||
commands = _.reject capitano.state.commands, (command) ->
|
commands = _.reject capitano.state.commands, (command) ->
|
||||||
return command.isWildcard()
|
return command.isWildcard()
|
||||||
|
|
||||||
print(parse(commands))
|
groupedCommands = _.groupBy commands, (command) ->
|
||||||
|
if command.plugin
|
||||||
|
return 'plugins'
|
||||||
|
else if command.primary
|
||||||
|
return 'primary'
|
||||||
|
return 'secondary'
|
||||||
|
|
||||||
|
print(parse(groupedCommands.primary))
|
||||||
|
|
||||||
|
if options.verbose
|
||||||
|
if not _.isEmpty(groupedCommands.plugins)
|
||||||
|
console.log('\nInstalled plugins:\n')
|
||||||
|
print(parse(groupedCommands.plugins))
|
||||||
|
|
||||||
|
console.log('\nAdditional commands:\n')
|
||||||
|
print(parse(groupedCommands.secondary))
|
||||||
|
else
|
||||||
|
console.log('\nRun `resin help --verbose` to list additional commands')
|
||||||
|
|
||||||
if not _.isEmpty(capitano.state.globalOptions)
|
if not _.isEmpty(capitano.state.globalOptions)
|
||||||
console.log('\nGlobal Options:\n')
|
console.log('\nGlobal Options:\n')
|
||||||
@ -76,6 +93,13 @@ exports.help =
|
|||||||
$ resin help apps
|
$ resin help apps
|
||||||
$ resin help os download
|
$ resin help os download
|
||||||
'''
|
'''
|
||||||
|
primary: true
|
||||||
|
options: [
|
||||||
|
signature: 'verbose'
|
||||||
|
description: 'show additional commands'
|
||||||
|
boolean: true
|
||||||
|
alias: 'v'
|
||||||
|
]
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
if params.command?
|
if params.command?
|
||||||
command(params, options, done)
|
command(params, options, done)
|
||||||
|
@ -29,6 +29,7 @@ module.exports =
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
promise = resin.logs.history(params.uuid).each (line) ->
|
promise = resin.logs.history(params.uuid).each (line) ->
|
||||||
console.log(line.message)
|
console.log(line.message)
|
||||||
|
@ -24,6 +24,7 @@ exports.wizard =
|
|||||||
$ sudo resin quickstart MyApp
|
$ sudo resin quickstart MyApp
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
return if params.name?
|
return if params.name?
|
||||||
|
@ -5,6 +5,7 @@ capitano = require('capitano')
|
|||||||
exports.register = (regex) ->
|
exports.register = (regex) ->
|
||||||
nplugm.list(regex).map (plugin) ->
|
nplugm.list(regex).map (plugin) ->
|
||||||
command = require(plugin)
|
command = require(plugin)
|
||||||
|
command.plugin = true
|
||||||
return capitano.command(command) if not _.isArray(command)
|
return capitano.command(command) if not _.isArray(command)
|
||||||
return _.each(command, capitano.command)
|
return _.each(command, capitano.command)
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user