mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 10:46:34 +00:00
Merge pull request #199 from resin-io/jviotti/feature/197/device-init-apps
Prompt for select application if running device init with no arguments
This commit is contained in:
commit
30d84f015a
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var Promise, _, capitano, commandOptions, events, form, fs, patterns, resin, rimraf, tmp, vcs, visuals;
|
||||
var Promise, _, capitano, commandOptions, events, form, fs, patterns, resin, rimraf, tmp, visuals;
|
||||
|
||||
Promise = require('bluebird');
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
form = require('resin-cli-form');
|
||||
|
||||
events = require('resin-cli-events');
|
||||
@ -141,7 +139,7 @@
|
||||
if (options.application != null) {
|
||||
return options.application;
|
||||
}
|
||||
return vcs.getApplicationName(process.cwd());
|
||||
return patterns.selectApplication();
|
||||
}).then(resin.models.application.get).then(function(application) {
|
||||
var download;
|
||||
download = function() {
|
||||
|
@ -24,7 +24,7 @@
|
||||
if (params.name != null) {
|
||||
return;
|
||||
}
|
||||
return patterns.selectApplication().tap(function(applicationName) {
|
||||
return patterns.selectOrCreateApplication().tap(function(applicationName) {
|
||||
return resin.models.application.has(applicationName).then(function(hasApplication) {
|
||||
if (hasApplication) {
|
||||
return applicationName;
|
||||
|
@ -41,6 +41,21 @@
|
||||
};
|
||||
|
||||
exports.selectApplication = function() {
|
||||
return resin.models.application.hasAny().then(function(hasAnyApplications) {
|
||||
if (!hasAnyApplications) {
|
||||
throw new Error('You don\'t have any applications');
|
||||
}
|
||||
return resin.models.application.getAll().then(function(applications) {
|
||||
return form.ask({
|
||||
message: 'Select an application',
|
||||
type: 'list',
|
||||
choices: _.pluck(applications, 'app_name')
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.selectOrCreateApplication = function() {
|
||||
return resin.models.application.hasAny().then(function(hasAnyApplications) {
|
||||
if (!hasAnyApplications) {
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ Now you have access to all the commands referenced below.
|
||||
- [device rm <uuid>](#device-rm-60-uuid-62-)
|
||||
- [device identify <uuid>](#device-identify-60-uuid-62-)
|
||||
- [device rename <uuid> [newName]](#device-rename-60-uuid-62-newname-)
|
||||
- [device init [device]](#device-init-device-)
|
||||
- [device init](#device-init)
|
||||
|
||||
- Environment Variables
|
||||
|
||||
@ -291,36 +291,17 @@ Examples:
|
||||
$ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 MyPi
|
||||
$ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
|
||||
|
||||
## device init [device]
|
||||
## device init
|
||||
|
||||
Use this command to download the OS image of a certain application and write it to an SD Card.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
Notice this command may ask for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar and other logging information by passing the `--quiet` boolean option.
|
||||
|
||||
You need to configure the network type and other settings:
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
You can omit network related options to be asked about them interactively.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device init
|
||||
$ resin device init --application MyApp
|
||||
$ resin device init --application MyApp --network ethernet
|
||||
$ resin device init /dev/disk2 --application MyApp --network wifi --ssid MyNetwork --key secret
|
||||
|
||||
### Options
|
||||
|
||||
@ -328,17 +309,9 @@ Examples:
|
||||
|
||||
application name
|
||||
|
||||
#### --network, -n <network>
|
||||
#### --yes, -y
|
||||
|
||||
network type
|
||||
|
||||
#### --ssid, -s <ssid>
|
||||
|
||||
wifi ssid, if network is wifi
|
||||
|
||||
#### --key, -k <key>
|
||||
|
||||
wifi key, if network is wifi
|
||||
confirm non interactively
|
||||
|
||||
# Environment Variables
|
||||
|
||||
|
@ -3,7 +3,6 @@ capitano = Promise.promisifyAll(require('capitano'))
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
vcs = require('resin-vcs')
|
||||
form = require('resin-cli-form')
|
||||
events = require('resin-cli-events')
|
||||
fs = Promise.promisifyAll(require('fs'))
|
||||
@ -194,7 +193,7 @@ exports.init =
|
||||
action: (params, options, done) ->
|
||||
Promise.try ->
|
||||
return options.application if options.application?
|
||||
return vcs.getApplicationName(process.cwd())
|
||||
return patterns.selectApplication()
|
||||
.then(resin.models.application.get)
|
||||
.then (application) ->
|
||||
|
||||
|
@ -28,7 +28,7 @@ exports.wizard =
|
||||
action: (params, options, done) ->
|
||||
Promise.try ->
|
||||
return if params.name?
|
||||
patterns.selectApplication().tap (applicationName) ->
|
||||
patterns.selectOrCreateApplication().tap (applicationName) ->
|
||||
resin.models.application.has(applicationName).then (hasApplication) ->
|
||||
return applicationName if hasApplication
|
||||
capitano.runAsync("app create #{applicationName}")
|
||||
|
@ -24,6 +24,17 @@ exports.confirm = (yesOption, message) ->
|
||||
throw new Error('Aborted')
|
||||
|
||||
exports.selectApplication = ->
|
||||
resin.models.application.hasAny().then (hasAnyApplications) ->
|
||||
if not hasAnyApplications
|
||||
throw new Error('You don\'t have any applications')
|
||||
|
||||
resin.models.application.getAll().then (applications) ->
|
||||
return form.ask
|
||||
message: 'Select an application'
|
||||
type: 'list'
|
||||
choices: _.pluck(applications, 'app_name')
|
||||
|
||||
exports.selectOrCreateApplication = ->
|
||||
resin.models.application.hasAny().then (hasAnyApplications) ->
|
||||
return if not hasAnyApplications
|
||||
resin.models.application.getAll().then (applications) ->
|
||||
|
Loading…
Reference in New Issue
Block a user