mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-12 07:52:46 +00:00
Accept names instead of ids in example commands
This commit is contained in:
parent
72d4b21cb4
commit
68ef069e6a
@ -35,41 +35,43 @@
|
|||||||
}
|
}
|
||||||
return example;
|
return example;
|
||||||
});
|
});
|
||||||
return console.log(visuals.widgets.table.horizontal(examplesData, ['id', 'display_name', 'repository', 'author']));
|
return console.log(visuals.widgets.table.horizontal(examplesData, ['id', 'name', 'display_name', 'repository', 'author']));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
signature: 'example <id>',
|
signature: 'example <name>',
|
||||||
description: 'list a single example application',
|
description: 'list a single example application',
|
||||||
help: 'Use this command to show information of a single example application\n\nExample:\n\n $ resin example 3',
|
help: 'Use this command to show information of a single example application\n\nExample:\n\n $ resin example cimon',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var example, id;
|
var example;
|
||||||
id = params.id - 1;
|
example = _.findWhere(examplesData, {
|
||||||
example = examplesData[id];
|
name: params.name
|
||||||
|
});
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
return done(new Error("Unknown example: " + id));
|
return done(new Error("Unknown example: " + params.name));
|
||||||
}
|
}
|
||||||
example.id = id;
|
|
||||||
if (example.author == null) {
|
if (example.author == null) {
|
||||||
example.author = 'Unknown';
|
example.author = 'Unknown';
|
||||||
}
|
}
|
||||||
console.log(visuals.widgets.table.vertical(example, ['id', 'display_name', 'description', 'author', 'repository']));
|
console.log(visuals.widgets.table.vertical(example, ['name', 'display_name', 'description', 'author', 'repository']));
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.clone = {
|
exports.clone = {
|
||||||
signature: 'example clone <id>',
|
signature: 'example clone <name>',
|
||||||
description: 'clone an example application',
|
description: 'clone an example application',
|
||||||
help: 'Use this command to clone an example application to the current directory\n\nThis command outputs information about the cloning process.\nUse `--quiet` to remove that output.\n\nExample:\n\n $ resin example clone 3',
|
help: 'Use this command to clone an example application to the current directory\n\nThis command outputs information about the cloning process.\nUse `--quiet` to remove that output.\n\nExample:\n\n $ resin example clone cimon',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var currentDirectory, destination, example;
|
var currentDirectory, destination, example;
|
||||||
example = examplesData[params.id - 1];
|
example = _.findWhere(examplesData, {
|
||||||
|
name: params.name
|
||||||
|
});
|
||||||
if (example == null) {
|
if (example == null) {
|
||||||
return done(new Error("Unknown example: " + id));
|
return done(new Error("Unknown example: " + params.name));
|
||||||
}
|
}
|
||||||
currentDirectory = process.cwd();
|
currentDirectory = process.cwd();
|
||||||
destination = path.join(currentDirectory, example.name);
|
destination = path.join(currentDirectory, example.name);
|
||||||
|
@ -30,34 +30,33 @@ exports.list =
|
|||||||
|
|
||||||
console.log visuals.widgets.table.horizontal examplesData, [
|
console.log visuals.widgets.table.horizontal examplesData, [
|
||||||
'id'
|
'id'
|
||||||
|
'name'
|
||||||
'display_name'
|
'display_name'
|
||||||
'repository'
|
'repository'
|
||||||
'author'
|
'author'
|
||||||
]
|
]
|
||||||
|
|
||||||
exports.info =
|
exports.info =
|
||||||
signature: 'example <id>'
|
signature: 'example <name>'
|
||||||
description: 'list a single example application'
|
description: 'list a single example application'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to show information of a single example application
|
Use this command to show information of a single example application
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ resin example 3
|
$ resin example cimon
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
id = params.id - 1
|
example = _.findWhere(examplesData, name: params.name)
|
||||||
example = examplesData[id]
|
|
||||||
|
|
||||||
if not example?
|
if not example?
|
||||||
return done(new Error("Unknown example: #{id}"))
|
return done(new Error("Unknown example: #{params.name}"))
|
||||||
|
|
||||||
example.id = id
|
|
||||||
example.author ?= 'Unknown'
|
example.author ?= 'Unknown'
|
||||||
|
|
||||||
console.log visuals.widgets.table.vertical example, [
|
console.log visuals.widgets.table.vertical example, [
|
||||||
'id'
|
'name'
|
||||||
'display_name'
|
'display_name'
|
||||||
'description'
|
'description'
|
||||||
'author'
|
'author'
|
||||||
@ -67,7 +66,7 @@ exports.info =
|
|||||||
return done()
|
return done()
|
||||||
|
|
||||||
exports.clone =
|
exports.clone =
|
||||||
signature: 'example clone <id>'
|
signature: 'example clone <name>'
|
||||||
description: 'clone an example application'
|
description: 'clone an example application'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to clone an example application to the current directory
|
Use this command to clone an example application to the current directory
|
||||||
@ -77,14 +76,14 @@ exports.clone =
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ resin example clone 3
|
$ resin example clone cimon
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
example = examplesData[params.id - 1]
|
example = _.findWhere(examplesData, name: params.name)
|
||||||
|
|
||||||
if not example?
|
if not example?
|
||||||
return done(new Error("Unknown example: #{id}"))
|
return done(new Error("Unknown example: #{params.name}"))
|
||||||
|
|
||||||
currentDirectory = process.cwd()
|
currentDirectory = process.cwd()
|
||||||
destination = path.join(currentDirectory, example.name)
|
destination = path.join(currentDirectory, example.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user