mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 15:32:22 +00:00
Make device init attempt to get application id from current directory
This commit is contained in:
parent
8410a709c9
commit
80e0f20301
@ -1,4 +1,8 @@
|
||||
(function() {
|
||||
var _;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
exports.yes = {
|
||||
signature: 'yes',
|
||||
description: 'confirm non interactively',
|
||||
@ -6,14 +10,17 @@
|
||||
alias: 'y'
|
||||
};
|
||||
|
||||
exports.application = {
|
||||
exports.optionalApplication = {
|
||||
signature: 'application',
|
||||
parameter: 'application',
|
||||
description: 'application id',
|
||||
alias: ['a', 'app'],
|
||||
required: 'You have to specify an application'
|
||||
alias: ['a', 'app']
|
||||
};
|
||||
|
||||
exports.application = _.defaults({
|
||||
required: 'You have to specify an application'
|
||||
}, exports.optionalApplication);
|
||||
|
||||
exports.network = {
|
||||
signature: 'network',
|
||||
parameter: 'network',
|
||||
|
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, osAction, path, resin, visuals;
|
||||
var _, async, commandOptions, osAction, path, resin, vcs, visuals;
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
osAction = require('./os');
|
||||
@ -110,12 +112,18 @@
|
||||
signature: 'device init [device]',
|
||||
description: 'initialise a device with resin os',
|
||||
help: 'Use this command to download the OS image of a certain application and write it to an SD Card.\n\nNote that this command requires admin privileges.\n\nIf `device` is omitted, you will be prompted to select a device interactively.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nYou can quiet the progress bar by passing the `--quiet` boolean option.\n\nYou may have to unmount the device before attempting this operation.\n\nYou need to configure the network type and other settings:\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\nYou can omit network related options to be asked about them interactively.\n\nExamples:\n\n $ resin device init --application 91\n $ resin device init --application 91 --network ethernet\n $ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret',
|
||||
options: [commandOptions.application, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
||||
options: [commandOptions.optionalApplication, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
params.id = options.application;
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (options.application != null) {
|
||||
return callback(null, options.application);
|
||||
}
|
||||
return vcs.getApplicationId(process.cwd(), callback);
|
||||
}, function(applicationId, callback) {
|
||||
params.id = applicationId;
|
||||
if (params.device != null) {
|
||||
return callback(null, params.device);
|
||||
}
|
||||
|
@ -1,15 +1,20 @@
|
||||
_ = require('lodash')
|
||||
|
||||
exports.yes =
|
||||
signature: 'yes'
|
||||
description: 'confirm non interactively'
|
||||
boolean: true
|
||||
alias: 'y'
|
||||
|
||||
exports.application =
|
||||
exports.optionalApplication =
|
||||
signature: 'application'
|
||||
parameter: 'application'
|
||||
description: 'application id'
|
||||
alias: [ 'a', 'app' ]
|
||||
|
||||
exports.application = _.defaults
|
||||
required: 'You have to specify an application'
|
||||
, exports.optionalApplication
|
||||
|
||||
exports.network =
|
||||
signature: 'network'
|
||||
|
@ -3,6 +3,7 @@ path = require('path')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
vcs = require('resin-vcs')
|
||||
commandOptions = require('./command-options')
|
||||
osAction = require('./os')
|
||||
|
||||
@ -181,7 +182,7 @@ exports.init =
|
||||
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
||||
'''
|
||||
options: [
|
||||
commandOptions.application
|
||||
commandOptions.optionalApplication
|
||||
commandOptions.network
|
||||
commandOptions.wifiSsid
|
||||
commandOptions.wifiKey
|
||||
@ -194,6 +195,11 @@ exports.init =
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
return callback(null, options.application) if options.application?
|
||||
vcs.getApplicationId(process.cwd(), callback)
|
||||
|
||||
(applicationId, callback) ->
|
||||
params.id = applicationId
|
||||
return callback(null, params.device) if params.device?
|
||||
visuals.patterns.selectDrive(callback)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user