mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 13:47:52 +00:00
Make os download command accept an application name instead of id
This commit is contained in:
parent
ac115c7ea3
commit
85444a5a6a
@ -26,9 +26,9 @@
|
||||
elevate = require('../elevate');
|
||||
|
||||
exports.download = {
|
||||
signature: 'os download <id>',
|
||||
signature: 'os download <name>',
|
||||
description: 'download device OS',
|
||||
help: 'Use this command to download the device OS configured to a specific network.\n\nEthernet:\n You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".\n\nWifi:\n You can setup the device OS to use wifi by setting the `--network` option to "wifi".\n If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.\n\nAlternatively, you can omit all kind of network configuration options to configure interactively.\n\nYou have to specify an output location with the `--output` option.\n\nExamples:\n\n $ resin os download 91 --output ~/MyResinOS.zip\n $ resin os download 91 --network ethernet --output ~/MyResinOS.zip\n $ resin os download 91 --network wifi --ssid MyNetwork --key secreykey123 --output ~/MyResinOS.zip\n $ resin os download 91 --network ethernet --output ~/MyResinOS.zip',
|
||||
help: 'Use this command to download the device OS configured to a specific network.\n\nEthernet:\n You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".\n\nWifi:\n You can setup the device OS to use wifi by setting the `--network` option to "wifi".\n If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.\n\nAlternatively, you can omit all kind of network configuration options to configure interactively.\n\nYou have to specify an output location with the `--output` option.\n\nExamples:\n\n $ resin os download MyApp --output ~/MyResinOS.zip\n $ resin os download MyApp --network ethernet --output ~/MyResinOS.zip\n $ resin os download MyApp --network wifi --ssid MyNetwork --key secreykey123 --output ~/MyResinOS.zip\n $ resin os download MyApp --network ethernet --output ~/MyResinOS.zip',
|
||||
options: [
|
||||
commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey, {
|
||||
signature: 'output',
|
||||
@ -40,51 +40,56 @@
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var osParams;
|
||||
osParams = {
|
||||
network: options.network,
|
||||
wifiSsid: options.ssid,
|
||||
wifiKey: options.key,
|
||||
appId: params.id
|
||||
};
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (osParams.network != null) {
|
||||
return callback();
|
||||
}
|
||||
return visuals.patterns.selectNetworkParameters(function(error, parameters) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
_.extend(osParams, parameters);
|
||||
return callback();
|
||||
});
|
||||
}, function(callback) {
|
||||
return mkdirp(path.dirname(options.output), _.unary(callback));
|
||||
}, function(callback) {
|
||||
var bar, spinner;
|
||||
console.info("Destination file: " + options.output + "\n");
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS');
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)');
|
||||
return resin.models.os.download(osParams, options.output, function(error) {
|
||||
spinner.stop();
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
}, function(state) {
|
||||
if (state != null) {
|
||||
return bar.update(state);
|
||||
} else {
|
||||
return spinner.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
], function(error) {
|
||||
return resin.models.application.get(params.name, function(error, application) {
|
||||
var osParams;
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.info("\nFinished downloading " + options.output);
|
||||
return done(null, options.output);
|
||||
osParams = {
|
||||
network: options.network,
|
||||
wifiSsid: options.ssid,
|
||||
wifiKey: options.key,
|
||||
appId: application.id
|
||||
};
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (osParams.network != null) {
|
||||
return callback();
|
||||
}
|
||||
return visuals.patterns.selectNetworkParameters(function(error, parameters) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
_.extend(osParams, parameters);
|
||||
return callback();
|
||||
});
|
||||
}, function(callback) {
|
||||
return mkdirp(path.dirname(options.output), _.unary(callback));
|
||||
}, function(callback) {
|
||||
var bar, spinner;
|
||||
console.info("Destination file: " + options.output + "\n");
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS');
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)');
|
||||
return resin.models.os.download(osParams, options.output, function(error) {
|
||||
spinner.stop();
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
}, function(state) {
|
||||
if (state != null) {
|
||||
return bar.update(state);
|
||||
} else {
|
||||
return spinner.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
], function(error) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.info("\nFinished downloading " + options.output);
|
||||
return done(null, options.output);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ updateActions = require('./update')
|
||||
elevate = require('../elevate')
|
||||
|
||||
exports.download =
|
||||
signature: 'os download <id>'
|
||||
signature: 'os download <name>'
|
||||
description: 'download device OS'
|
||||
help: '''
|
||||
Use this command to download the device OS configured to a specific network.
|
||||
@ -30,10 +30,10 @@ exports.download =
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os download 91 --output ~/MyResinOS.zip
|
||||
$ resin os download 91 --network ethernet --output ~/MyResinOS.zip
|
||||
$ resin os download 91 --network wifi --ssid MyNetwork --key secreykey123 --output ~/MyResinOS.zip
|
||||
$ resin os download 91 --network ethernet --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network ethernet --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network wifi --ssid MyNetwork --key secreykey123 --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network ethernet --output ~/MyResinOS.zip
|
||||
'''
|
||||
options: [
|
||||
commandOptions.network
|
||||
@ -50,45 +50,48 @@ exports.download =
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
osParams =
|
||||
network: options.network
|
||||
wifiSsid: options.ssid
|
||||
wifiKey: options.key
|
||||
appId: params.id
|
||||
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
return callback() if osParams.network?
|
||||
visuals.patterns.selectNetworkParameters (error, parameters) ->
|
||||
return callback(error) if error?
|
||||
_.extend(osParams, parameters)
|
||||
return callback()
|
||||
|
||||
(callback) ->
|
||||
|
||||
# We need to ensure this directory exists
|
||||
mkdirp(path.dirname(options.output), _.unary(callback))
|
||||
|
||||
(callback) ->
|
||||
console.info("Destination file: #{options.output}\n")
|
||||
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS')
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)')
|
||||
|
||||
resin.models.os.download osParams, options.output, (error) ->
|
||||
spinner.stop()
|
||||
return callback(error) if error?
|
||||
, (state) ->
|
||||
if state?
|
||||
bar.update(state)
|
||||
else
|
||||
spinner.start()
|
||||
|
||||
], (error) ->
|
||||
resin.models.application.get params.name, (error, application) ->
|
||||
return done(error) if error?
|
||||
console.info("\nFinished downloading #{options.output}")
|
||||
return done(null, options.output)
|
||||
|
||||
osParams =
|
||||
network: options.network
|
||||
wifiSsid: options.ssid
|
||||
wifiKey: options.key
|
||||
appId: application.id
|
||||
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
return callback() if osParams.network?
|
||||
visuals.patterns.selectNetworkParameters (error, parameters) ->
|
||||
return callback(error) if error?
|
||||
_.extend(osParams, parameters)
|
||||
return callback()
|
||||
|
||||
(callback) ->
|
||||
|
||||
# We need to ensure this directory exists
|
||||
mkdirp(path.dirname(options.output), _.unary(callback))
|
||||
|
||||
(callback) ->
|
||||
console.info("Destination file: #{options.output}\n")
|
||||
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS')
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)')
|
||||
|
||||
resin.models.os.download osParams, options.output, (error) ->
|
||||
spinner.stop()
|
||||
return callback(error) if error?
|
||||
, (state) ->
|
||||
if state?
|
||||
bar.update(state)
|
||||
else
|
||||
spinner.start()
|
||||
|
||||
], (error) ->
|
||||
return done(error) if error?
|
||||
console.info("\nFinished downloading #{options.output}")
|
||||
return done(null, options.output)
|
||||
|
||||
exports.install =
|
||||
signature: 'os install <image> [device]'
|
||||
|
Loading…
Reference in New Issue
Block a user