mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-06-25 02:47:55 +00:00
Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
b29ce3ee04 | |||
2b4394f3ce | |||
60f704eaa9 | |||
caa4fcf754 | |||
c4d1e4244e | |||
a6dc155028 | |||
9c65d11e66 | |||
26f50e7a74 | |||
e4773da1d7 | |||
dfd8086f63 | |||
ec513c61ad | |||
a96ab487ba | |||
cd28c985ce | |||
727af42ad4 | |||
e96d411f3e | |||
4a7d3d5945 | |||
03f05305cf | |||
af6e9ef85d | |||
8533a4a303 | |||
85f9234c74 | |||
064afd6705 | |||
978ff91f87 | |||
5cebbce7bb | |||
1cd0f02db5 | |||
77695bb505 | |||
4e4428fdbb | |||
6e978d74dd | |||
58974af77b | |||
11a0eae7a0 | |||
2a4ba895e5 | |||
19c019076e | |||
dfa18d3cb3 | |||
782c92885d | |||
a14dfa6cf1 | |||
f3b6f9d117 | |||
63b2b3feb6 | |||
9237dd25ac | |||
df9c4ce2fd | |||
fa5a7abbbf | |||
cd8bb7882e | |||
3c0378142a | |||
a524bffaa2 | |||
4b3decbe03 | |||
fa258a84cc | |||
5efa7309be | |||
6e6a01c33c | |||
94ce15bc2c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,3 +32,4 @@ bin/node
|
|||||||
release/build
|
release/build
|
||||||
|
|
||||||
npm-shrinkwrap.json
|
npm-shrinkwrap.json
|
||||||
|
.resinconf
|
||||||
|
5
.hound.yml
Normal file
5
.hound.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
coffee_script:
|
||||||
|
config_file: coffeelint.json
|
||||||
|
|
||||||
|
java_script:
|
||||||
|
enabled: false
|
@ -50,7 +50,7 @@
|
|||||||
exports.list = {
|
exports.list = {
|
||||||
signature: 'apps',
|
signature: 'apps',
|
||||||
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 <id> 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',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.getAll(function(error, applications) {
|
return resin.models.application.getAll(function(error, applications) {
|
||||||
@ -64,12 +64,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
signature: 'app <id>',
|
signature: 'app <name>',
|
||||||
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 91',
|
help: 'Use this command to show detailed information for a single application.\n\nExamples:\n\n $ resin app MyApp',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.get(params.id, function(error, application) {
|
return resin.models.application.get(params.name, function(error, application) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return done(error);
|
return done(error);
|
||||||
}
|
}
|
||||||
@ -80,32 +80,32 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.restart = {
|
exports.restart = {
|
||||||
signature: 'app restart <id>',
|
signature: 'app restart <name>',
|
||||||
description: 'restart an application',
|
description: 'restart an application',
|
||||||
help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart 91',
|
help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart MyApp',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.restart(params.id, done);
|
return resin.models.application.restart(params.name, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.remove = {
|
exports.remove = {
|
||||||
signature: 'app rm <id>',
|
signature: 'app rm <name>',
|
||||||
description: 'remove an application',
|
description: 'remove an application',
|
||||||
help: 'Use this command to remove a resin.io application.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app rm 91\n $ resin app rm 91 --yes',
|
help: 'Use this command to remove a resin.io application.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app rm MyApp\n $ resin app rm MyApp --yes',
|
||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return visuals.patterns.remove('application', options.yes, function(callback) {
|
return visuals.patterns.remove('application', options.yes, function(callback) {
|
||||||
return resin.models.application.remove(params.id, callback);
|
return resin.models.application.remove(params.name, callback);
|
||||||
}, done);
|
}, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.associate = {
|
exports.associate = {
|
||||||
signature: 'app associate <id>',
|
signature: 'app associate <name>',
|
||||||
description: 'associate a resin project',
|
description: 'associate a resin project',
|
||||||
help: 'Use this command to associate a project directory with a resin application.\n\nThis command adds a \'resin\' git remote to the directory and runs git init if necessary.\n\nExamples:\n\n $ resin app associate 91\n $ resin app associate 91 --project my/app/directory',
|
help: 'Use this command to associate a project directory with a resin application.\n\nThis command adds a \'resin\' git remote to the directory and runs git init if necessary.\n\nExamples:\n\n $ resin app associate MyApp\n $ resin app associate MyApp --project my/app/directory',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var currentDirectory;
|
var currentDirectory;
|
||||||
@ -114,7 +114,7 @@
|
|||||||
function(callback) {
|
function(callback) {
|
||||||
return vcs.initialize(currentDirectory, callback);
|
return vcs.initialize(currentDirectory, callback);
|
||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
return resin.models.application.get(params.id, callback);
|
return resin.models.application.get(params.name, callback);
|
||||||
}, function(application, callback) {
|
}, function(application, callback) {
|
||||||
return vcs.addRemote(currentDirectory, application.git_repository, callback);
|
return vcs.addRemote(currentDirectory, application.git_repository, callback);
|
||||||
}
|
}
|
||||||
@ -144,10 +144,15 @@
|
|||||||
}, function(applicationName, callback) {
|
}, function(applicationName, callback) {
|
||||||
return exports.create.action({
|
return exports.create.action({
|
||||||
name: applicationName
|
name: applicationName
|
||||||
}, options, callback);
|
}, options, function(error) {
|
||||||
}, function(applicationId, callback) {
|
if (error != null) {
|
||||||
|
return callback(error);
|
||||||
|
}
|
||||||
|
return callback(null, applicationName);
|
||||||
|
});
|
||||||
|
}, function(applicationName, callback) {
|
||||||
return exports.associate.action({
|
return exports.associate.action({
|
||||||
id: applicationId
|
name: applicationName
|
||||||
}, options, callback);
|
}, options, callback);
|
||||||
}
|
}
|
||||||
], done);
|
], done);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var _, async, resin, url, visuals;
|
var TOKEN_URL, _, async, open, resin, settings, url, visuals;
|
||||||
|
|
||||||
|
open = require('open');
|
||||||
|
|
||||||
_ = require('lodash-contrib');
|
_ = require('lodash-contrib');
|
||||||
|
|
||||||
@ -9,45 +11,49 @@
|
|||||||
|
|
||||||
resin = require('resin-sdk');
|
resin = require('resin-sdk');
|
||||||
|
|
||||||
|
settings = require('resin-settings-client');
|
||||||
|
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
|
|
||||||
exports.login = {
|
exports.whoami = {
|
||||||
signature: 'login',
|
signature: 'whoami',
|
||||||
description: 'login to resin.io',
|
description: 'whoami',
|
||||||
help: 'Use this command to login to your resin.io account.\nYou need to login before you can use most of the commands this tool provides.\n\nYou can pass your credentials as `--username` and `--password` options, or you can omit the\ncredentials, in which case the tool will present you with an interactive login form.\n\nExamples:\n\n $ resin login --username <username> --password <password>\n $ resin login',
|
help: 'Use this command to get the logged in user name.\n\nExamples:\n\n $ resin whoami',
|
||||||
options: [
|
permission: 'user',
|
||||||
{
|
|
||||||
signature: 'username',
|
|
||||||
parameter: 'username',
|
|
||||||
description: 'user name',
|
|
||||||
alias: 'u'
|
|
||||||
}, {
|
|
||||||
signature: 'password',
|
|
||||||
parameter: 'password',
|
|
||||||
description: 'user password',
|
|
||||||
alias: 'p'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var hasOptionCredentials;
|
return resin.auth.whoami(function(error, username) {
|
||||||
hasOptionCredentials = !_.isEmpty(options);
|
if (error != null) {
|
||||||
if (hasOptionCredentials) {
|
return done(error);
|
||||||
if (!options.username) {
|
|
||||||
return done(new Error('Missing username'));
|
|
||||||
}
|
}
|
||||||
if (!options.password) {
|
console.log(username);
|
||||||
return done(new Error('Missing password'));
|
return done();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TOKEN_URL = url.resolve(settings.get('remoteUrl'), '/preferences');
|
||||||
|
|
||||||
|
exports.login = {
|
||||||
|
signature: 'login [token]',
|
||||||
|
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\n " + TOKEN_URL + "\n\nExamples:\n\n $ resin login\n $ resin login \"eyJ0eXAiOiJKV1Qi...\"",
|
||||||
|
action: function(params, options, done) {
|
||||||
|
console.info("To login to the Resin CLI, you need your unique token, which is accesible from\nthe preferences page at " + TOKEN_URL + "\n\nAttempting to open a browser at that location...");
|
||||||
return async.waterfall([
|
return async.waterfall([
|
||||||
function(callback) {
|
function(callback) {
|
||||||
if (hasOptionCredentials) {
|
return open(TOKEN_URL, function(error) {
|
||||||
return callback(null, options);
|
if (error != null) {
|
||||||
} else {
|
console.error("Unable to open a web browser in the current environment.\nPlease visit " + TOKEN_URL + " manually.");
|
||||||
return visuals.widgets.login(callback);
|
}
|
||||||
|
return callback();
|
||||||
|
});
|
||||||
|
}, function(callback) {
|
||||||
|
if (params.token != null) {
|
||||||
|
return callback(null, params.token);
|
||||||
}
|
}
|
||||||
}, function(credentials, callback) {
|
return visuals.widgets.ask('What\'s your token? (visible in the preferences page)', null, callback);
|
||||||
return resin.auth.login(credentials, callback);
|
}, function(token, callback) {
|
||||||
|
return resin.auth.loginWithToken(token, done);
|
||||||
}
|
}
|
||||||
], done);
|
], done);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
exports.optionalApplication = {
|
exports.optionalApplication = {
|
||||||
signature: 'application',
|
signature: 'application',
|
||||||
parameter: 'application',
|
parameter: 'application',
|
||||||
description: 'application id',
|
description: 'application name',
|
||||||
alias: ['a', 'app']
|
alias: ['a', 'app']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
exports.list = {
|
exports.list = {
|
||||||
signature: 'devices',
|
signature: 'devices',
|
||||||
description: 'list all devices',
|
description: 'list all devices',
|
||||||
help: 'Use this command to list all devices that belong to a certain application.\n\nExamples:\n\n $ resin devices --application 91',
|
help: 'Use this command to list all devices that belong to a certain application.\n\nExamples:\n\n $ resin devices --application MyApp',
|
||||||
options: [commandOptions.application],
|
options: [commandOptions.application],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
@ -35,12 +35,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
signature: 'device <id>',
|
signature: 'device <name>',
|
||||||
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 317',
|
help: 'Use this command to show information about a single device.\n\nExamples:\n\n $ resin device MyDevice',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.device.get(params.id, function(error, device) {
|
return resin.models.device.get(params.name, function(error, device) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return done(error);
|
return done(error);
|
||||||
}
|
}
|
||||||
@ -51,14 +51,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.remove = {
|
exports.remove = {
|
||||||
signature: 'device rm <id>',
|
signature: 'device rm <name>',
|
||||||
description: 'remove a device',
|
description: 'remove a device',
|
||||||
help: 'Use this command to remove a device from resin.io.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device rm 317\n $ resin device rm 317 --yes',
|
help: 'Use this command to remove a device from resin.io.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device rm MyDevice\n $ resin device rm MyDevice --yes',
|
||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return visuals.patterns.remove('device', options.yes, function(callback) {
|
return visuals.patterns.remove('device', options.yes, function(callback) {
|
||||||
return resin.models.device.remove(params.id, callback);
|
return resin.models.device.remove(params.name, callback);
|
||||||
}, done);
|
}, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -74,19 +74,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.rename = {
|
exports.rename = {
|
||||||
signature: 'device rename <id> [name]',
|
signature: 'device rename <name> [newName]',
|
||||||
description: 'rename a resin device',
|
description: 'rename a resin device',
|
||||||
help: 'Use this command to rename a device.\n\nIf you omit the name, you\'ll get asked for it interactively.\n\nExamples:\n\n $ resin device rename 317 MyPi\n $ resin device rename 317',
|
help: 'Use this command to rename a device.\n\nIf you omit the name, you\'ll get asked for it interactively.\n\nExamples:\n\n $ resin device rename MyDevice MyPi\n $ resin device rename MyDevice',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return async.waterfall([
|
return async.waterfall([
|
||||||
function(callback) {
|
function(callback) {
|
||||||
if (!_.isEmpty(params.name)) {
|
if (!_.isEmpty(params.newName)) {
|
||||||
return callback(null, params.name);
|
return callback(null, params.newName);
|
||||||
}
|
}
|
||||||
return visuals.widgets.ask('How do you want to name this device?', null, callback);
|
return visuals.widgets.ask('How do you want to name this device?', null, callback);
|
||||||
}, function(name, callback) {
|
}, function(newName, callback) {
|
||||||
return resin.models.device.rename(params.id, name, callback);
|
return resin.models.device.rename(params.name, newName, callback);
|
||||||
}
|
}
|
||||||
], done);
|
], done);
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@
|
|||||||
exports.init = {
|
exports.init = {
|
||||||
signature: 'device init [device]',
|
signature: 'device init [device]',
|
||||||
description: 'initialise a device with resin os',
|
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',
|
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\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.optionalApplication, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
options: [commandOptions.optionalApplication, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
@ -129,8 +129,10 @@
|
|||||||
}
|
}
|
||||||
return visuals.patterns.selectDrive(callback);
|
return visuals.patterns.selectDrive(callback);
|
||||||
}, function(device, callback) {
|
}, function(device, callback) {
|
||||||
|
var message;
|
||||||
params.device = device;
|
params.device = device;
|
||||||
return visuals.patterns.confirm(options.yes, "This will completely erase " + params.device + ". Are you sure you want to continue?", callback);
|
message = "This will completely erase " + params.device + ". Are you sure you want to continue?";
|
||||||
|
return visuals.patterns.confirm(options.yes, message, callback);
|
||||||
}, function(confirmed, callback) {
|
}, function(confirmed, callback) {
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return done();
|
return done();
|
||||||
|
@ -6,10 +6,9 @@
|
|||||||
exports.version = {
|
exports.version = {
|
||||||
signature: 'version',
|
signature: 'version',
|
||||||
description: 'output the version number',
|
description: 'output the version number',
|
||||||
help: 'Display the Resin CLI, as well as the bundled NodeJS version.',
|
help: 'Display the Resin CLI version.',
|
||||||
action: function() {
|
action: function() {
|
||||||
console.log(packageJSON.name + ": " + packageJSON.version);
|
return console.log(packageJSON.version);
|
||||||
return console.log("node: " + process.version);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var _, async, capitano, commandOptions, fs, resin, visuals;
|
var SSH_KEY_WIDTH, _, async, capitano, commandOptions, fs, resin, visuals;
|
||||||
|
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
|
|
||||||
@ -33,6 +33,8 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SSH_KEY_WIDTH = 43;
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
signature: 'key <id>',
|
signature: 'key <id>',
|
||||||
description: 'list a single ssh key',
|
description: 'list a single ssh key',
|
||||||
@ -40,12 +42,10 @@
|
|||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.key.get(params.id, function(error, key) {
|
return resin.models.key.get(params.id, function(error, key) {
|
||||||
var sshKeyWidth;
|
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return done(error);
|
return done(error);
|
||||||
}
|
}
|
||||||
sshKeyWidth = resin.settings.get('sshKeyWidth');
|
key.public_key = '\n' + visuals.helpers.chop(key.public_key, SSH_KEY_WIDTH);
|
||||||
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth);
|
|
||||||
console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key']));
|
console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key']));
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
exports.set = {
|
exports.set = {
|
||||||
signature: 'note <|note>',
|
signature: 'note <|note>',
|
||||||
description: 'set a device note',
|
description: 'set a device note',
|
||||||
help: 'Use this command to set or update a device note.\n\nIf note command isn\'t passed, the tool attempts to read from `stdin`.\n\nTo view the notes, use $ resin device <id>.\n\nExamples:\n\n $ resin note "My useful note" --device 317\n $ cat note.txt | resin note --device 317',
|
help: 'Use this command to set or update a device note.\n\nIf note command isn\'t passed, the tool attempts to read from `stdin`.\n\nTo view the notes, use $ resin device <name>.\n\nExamples:\n\n $ resin note "My useful note" --device MyDevice\n $ cat note.txt | resin note --device MyDevice',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
signature: 'device',
|
signature: 'device',
|
||||||
parameter: 'device',
|
parameter: 'device',
|
||||||
description: 'device id',
|
description: 'device name',
|
||||||
alias: ['d', 'dev'],
|
alias: ['d', 'dev'],
|
||||||
required: 'You have to specify a device'
|
required: 'You have to specify a device'
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var _, async, commandOptions, diskio, fs, mkdirp, npm, os, packageJSON, path, progressStream, resin, updateActions, visuals;
|
var _, async, commandOptions, elevate, mkdirp, npm, os, packageJSON, path, resin, updateActions, visuals;
|
||||||
|
|
||||||
_ = require('lodash-contrib');
|
_ = require('lodash-contrib');
|
||||||
|
|
||||||
fs = require('fs');
|
|
||||||
|
|
||||||
os = require('os');
|
os = require('os');
|
||||||
|
|
||||||
async = require('async');
|
async = require('async');
|
||||||
@ -17,10 +15,6 @@
|
|||||||
|
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
|
|
||||||
progressStream = require('progress-stream');
|
|
||||||
|
|
||||||
diskio = require('diskio');
|
|
||||||
|
|
||||||
commandOptions = require('./command-options');
|
commandOptions = require('./command-options');
|
||||||
|
|
||||||
npm = require('../npm');
|
npm = require('../npm');
|
||||||
@ -29,6 +23,8 @@
|
|||||||
|
|
||||||
updateActions = require('./update');
|
updateActions = require('./update');
|
||||||
|
|
||||||
|
elevate = require('../elevate');
|
||||||
|
|
||||||
exports.download = {
|
exports.download = {
|
||||||
signature: 'os download <id>',
|
signature: 'os download <id>',
|
||||||
description: 'download device OS',
|
description: 'download device OS',
|
||||||
@ -66,11 +62,21 @@
|
|||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
return mkdirp(path.dirname(options.output), _.unary(callback));
|
return mkdirp(path.dirname(options.output), _.unary(callback));
|
||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
var bar;
|
var bar, spinner;
|
||||||
console.info("Destination file: " + options.output + "\n");
|
console.info("Destination file: " + options.output + "\n");
|
||||||
bar = new visuals.widgets.Progress('Downloading Device OS');
|
bar = new visuals.widgets.Progress('Downloading Device OS');
|
||||||
return resin.models.os.download(osParams, options.output, callback, function(state) {
|
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)');
|
||||||
return bar.update(state);
|
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) {
|
], function(error) {
|
||||||
@ -90,6 +96,8 @@
|
|||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
|
var bundle;
|
||||||
|
bundle = require('../devices/raspberry-pi');
|
||||||
return async.waterfall([
|
return async.waterfall([
|
||||||
function(callback) {
|
function(callback) {
|
||||||
return npm.isUpdated(packageJSON.name, packageJSON.version, callback);
|
return npm.isUpdated(packageJSON.name, packageJSON.version, callback);
|
||||||
@ -98,7 +106,7 @@
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
console.info('Resin CLI is outdated.\n\nIn order to avoid device compatibility issues, this command\nrequires that you have the Resin CLI updated.\n\nUpdating now...');
|
console.info('Resin CLI is outdated.\n\nIn order to avoid device compatibility issues, this command\nrequires that you have the Resin CLI updated.\n\nUpdating now...');
|
||||||
return updateActions.update.action(params, options, _.unary(done));
|
return updateActions.update.action(params, options, _.unary(callback));
|
||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
if (params.device != null) {
|
if (params.device != null) {
|
||||||
return callback(null, params.device);
|
return callback(null, params.device);
|
||||||
@ -118,37 +126,22 @@
|
|||||||
message = "This will completely erase " + params.device + ". Are you sure you want to continue?";
|
message = "This will completely erase " + params.device + ". Are you sure you want to continue?";
|
||||||
return visuals.patterns.confirm(options.yes, message, callback);
|
return visuals.patterns.confirm(options.yes, message, callback);
|
||||||
}, function(confirmed, callback) {
|
}, function(confirmed, callback) {
|
||||||
var bar, error, imageFileSize, imageFileStream, progress;
|
var bar;
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
imageFileSize = fs.statSync(params.image).size;
|
bar = new visuals.widgets.Progress('Writing Device OS');
|
||||||
if (imageFileSize === 0) {
|
params.progress = _.bind(bar.update, bar);
|
||||||
error = new Error("Invalid OS image: " + params.image + ". The image is 0 bytes.");
|
return bundle.write(params, callback);
|
||||||
return callback(error);
|
|
||||||
}
|
|
||||||
progress = progressStream({
|
|
||||||
length: imageFileSize,
|
|
||||||
time: 500
|
|
||||||
});
|
|
||||||
if (!options.quiet) {
|
|
||||||
bar = new visuals.widgets.Progress('Writing Device OS');
|
|
||||||
progress.on('progress', function(status) {
|
|
||||||
return bar.update(status);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
imageFileStream = fs.createReadStream(params.image).pipe(progress);
|
|
||||||
return diskio.writeStream(params.device, imageFileStream, callback);
|
|
||||||
}
|
}
|
||||||
], function(error) {
|
], function(error) {
|
||||||
var resinWritePath, windosu;
|
var resinWritePath;
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
if (_.all([os.platform() === 'win32', error.code === 'EPERM' || error.code === 'EACCES', !options.fromScript])) {
|
if (elevate.shouldElevate(error) && !options.fromScript) {
|
||||||
windosu = require('windosu');
|
|
||||||
resinWritePath = "\"" + (path.join(__dirname, '..', '..', 'bin', 'resin-write')) + "\"";
|
resinWritePath = "\"" + (path.join(__dirname, '..', '..', 'bin', 'resin-write')) + "\"";
|
||||||
return windosu.exec("\"" + process.argv[0] + "\" " + resinWritePath + " \"" + params.image + "\" \"" + params.device + "\"");
|
return elevate.run("\"" + process.argv[0] + "\" " + resinWritePath + " \"" + params.image + "\" \"" + params.device + "\"");
|
||||||
} else {
|
} else {
|
||||||
return done(error);
|
return done(error);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var open, resin, url;
|
var open, settings, url;
|
||||||
|
|
||||||
open = require('open');
|
open = require('open');
|
||||||
|
|
||||||
url = require('url');
|
url = require('url');
|
||||||
|
|
||||||
resin = require('resin-sdk');
|
settings = require('resin-settings-client');
|
||||||
|
|
||||||
exports.preferences = {
|
exports.preferences = {
|
||||||
signature: 'preferences',
|
signature: 'preferences',
|
||||||
@ -13,9 +13,8 @@
|
|||||||
help: 'Use this command to open the preferences form.\n\nIn the future, we will allow changing all preferences directly from the terminal.\nFor now, we open your default web browser and point it to the web based preferences form.\n\nExamples:\n\n $ resin preferences',
|
help: 'Use this command to open the preferences form.\n\nIn the future, we will allow changing all preferences directly from the terminal.\nFor now, we open your default web browser and point it to the web based preferences form.\n\nExamples:\n\n $ resin preferences',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function() {
|
action: function() {
|
||||||
var absUrl, preferencesUrl;
|
var absUrl;
|
||||||
preferencesUrl = resin.settings.get('urls.preferences');
|
absUrl = url.resolve(settings.get('remoteUrl'), '/preferences');
|
||||||
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl);
|
|
||||||
return open(absUrl);
|
return open(absUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var npm, packageJSON;
|
var _, child_process, npm, packageJSON, president;
|
||||||
|
|
||||||
|
_ = require('lodash');
|
||||||
|
|
||||||
|
child_process = require('child_process');
|
||||||
|
|
||||||
|
president = require('president');
|
||||||
|
|
||||||
npm = require('../npm');
|
npm = require('../npm');
|
||||||
|
|
||||||
@ -10,12 +16,34 @@
|
|||||||
description: 'update the resin cli',
|
description: 'update the resin cli',
|
||||||
help: 'Use this command to update the Resin CLI\n\nThis command outputs information about the update process.\nUse `--quiet` to remove that output.\n\nThe Resin CLI checks for updates once per day.\n\nMajor updates require a manual update with this update command,\nwhile minor updates are applied automatically.\n\nExamples:\n\n $ resin update',
|
help: 'Use this command to update the Resin CLI\n\nThis command outputs information about the update process.\nUse `--quiet` to remove that output.\n\nThe Resin CLI checks for updates once per day.\n\nMajor updates require a manual update with this update command,\nwhile minor updates are applied automatically.\n\nExamples:\n\n $ resin update',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return npm.update(packageJSON.name, function(error, version) {
|
return npm.isUpdated(packageJSON.name, packageJSON.version, function(error, isUpdated) {
|
||||||
|
var command, onUpdate;
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return done(error);
|
return done(error);
|
||||||
}
|
}
|
||||||
console.info("Upgraded " + packageJSON.name + " to v" + version + ".");
|
if (isUpdated) {
|
||||||
return done(null, version);
|
return done(new Error('You\'re already running the latest version.'));
|
||||||
|
}
|
||||||
|
onUpdate = function(error, stdout, stderr) {
|
||||||
|
if (error != null) {
|
||||||
|
return done(error);
|
||||||
|
}
|
||||||
|
if (!_.isEmpty(stderr)) {
|
||||||
|
return done(new Error(stderr));
|
||||||
|
}
|
||||||
|
console.info("Upgraded " + packageJSON.name + ".");
|
||||||
|
return done();
|
||||||
|
};
|
||||||
|
command = "npm install --global " + packageJSON.name;
|
||||||
|
return child_process.exec(command, function(error, stdout, stderr) {
|
||||||
|
if (error != null) {
|
||||||
|
return onUpdate(null, stdout, stderr);
|
||||||
|
}
|
||||||
|
if (_.any([error.code === 3, error.code === 'EPERM', error.code === 'ACCES'])) {
|
||||||
|
return president.execute(command, onUpdate);
|
||||||
|
}
|
||||||
|
return done(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -152,10 +152,6 @@
|
|||||||
return update.check(callback);
|
return update.check(callback);
|
||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
return plugins.register('resin-plugin-', callback);
|
return plugins.register('resin-plugin-', callback);
|
||||||
}, function(callback) {
|
|
||||||
var dataPrefix;
|
|
||||||
dataPrefix = resin.settings.get('dataPrefix');
|
|
||||||
return resin.data.prefix.set(dataPrefix, callback);
|
|
||||||
}, function(callback) {
|
}, function(callback) {
|
||||||
var cli;
|
var cli;
|
||||||
cli = capitano.parse(process.argv);
|
cli = capitano.parse(process.argv);
|
||||||
|
30
build/devices/raspberry-pi.js
Normal file
30
build/devices/raspberry-pi.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
(function() {
|
||||||
|
var diskio, fs, progressStream;
|
||||||
|
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
progressStream = require('progress-stream');
|
||||||
|
|
||||||
|
diskio = require('diskio');
|
||||||
|
|
||||||
|
exports.name = 'Raspberry Pi';
|
||||||
|
|
||||||
|
exports.write = function(options, callback) {
|
||||||
|
var error, imageFileSize, imageFileStream, progress;
|
||||||
|
imageFileSize = fs.statSync(options.image).size;
|
||||||
|
if (imageFileSize === 0) {
|
||||||
|
error = new Error("Invalid OS image: " + options.image + ". The image is 0 bytes.");
|
||||||
|
return callback(error);
|
||||||
|
}
|
||||||
|
progress = progressStream({
|
||||||
|
length: imageFileSize,
|
||||||
|
time: 500
|
||||||
|
});
|
||||||
|
if (!options.quiet) {
|
||||||
|
progress.on('progress', options.progress);
|
||||||
|
}
|
||||||
|
imageFileStream = fs.createReadStream(options.image).pipe(progress);
|
||||||
|
return diskio.writeStream(options.device, imageFileStream, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(this);
|
25
build/elevate.js
Normal file
25
build/elevate.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
(function() {
|
||||||
|
var _, isWindows, os, path;
|
||||||
|
|
||||||
|
_ = require('lodash');
|
||||||
|
|
||||||
|
os = require('os');
|
||||||
|
|
||||||
|
path = require('path');
|
||||||
|
|
||||||
|
isWindows = function() {
|
||||||
|
return os.platform() === 'win32';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.shouldElevate = function(error) {
|
||||||
|
return _.all([isWindows(), error.code === 'EPERM' || error.code === 'EACCES']);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.run = function(command) {
|
||||||
|
if (!isWindows()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return require('windosu').exec(command);
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(this);
|
25
build/npm.js
25
build/npm.js
@ -7,31 +7,6 @@
|
|||||||
|
|
||||||
_ = require('lodash-contrib');
|
_ = require('lodash-contrib');
|
||||||
|
|
||||||
exports.update = function(name, callback) {
|
|
||||||
return async.waterfall([
|
|
||||||
function(callback) {
|
|
||||||
var options;
|
|
||||||
options = {
|
|
||||||
loglevel: 'silent',
|
|
||||||
global: true
|
|
||||||
};
|
|
||||||
return npm.load(options, _.unary(callback));
|
|
||||||
}, function(callback) {
|
|
||||||
return npm.commands.update([name], function(error, data) {
|
|
||||||
return callback(error, data);
|
|
||||||
});
|
|
||||||
}, function(data, callback) {
|
|
||||||
var error, newVersion;
|
|
||||||
if (_.isEmpty(data)) {
|
|
||||||
error = new Error('You are already running the latest version');
|
|
||||||
return callback(error);
|
|
||||||
}
|
|
||||||
newVersion = _.last(_.first(_.last(data)).split('@'));
|
|
||||||
return callback(null, newVersion);
|
|
||||||
}
|
|
||||||
], callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getLatestVersion = function(name, callback) {
|
exports.getLatestVersion = function(name, callback) {
|
||||||
return async.waterfall([
|
return async.waterfall([
|
||||||
function(callback) {
|
function(callback) {
|
||||||
|
96
capitanodoc.json
Normal file
96
capitanodoc.json
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"title": "Resin CLI Documentation",
|
||||||
|
"introduction": "This tool allows you to interact with the resin.io api from the comfort of your command line.\n\nTo get started download the CLI from npm.\n\n\t$ npm install resin-cli -g\n\nThen authenticate yourself:\n\n\t$ resin login\n\nNow you have access to all the commands referenced below.",
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "Application",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/app.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Authentication",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/auth.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Device",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/device.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Drive",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/drive.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Environment Variables",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/environment-variables.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Examples",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/examples.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Help",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/help.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Information",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/info.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Keys",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/keys.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Logs",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/logs.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Notes",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/notes.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OS",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/os.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Plugin",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/plugin.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Preferences",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/preferences.coffee"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Update",
|
||||||
|
"files": [
|
||||||
|
"lib/actions/update.coffee"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
# app associate <id>
|
|
||||||
|
|
||||||
Use this command to associate a project directory with a resin application.
|
|
||||||
|
|
||||||
This command adds a 'resin' git remote to the directory and runs git init if necessary.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin app associate 91
|
|
||||||
$ resin app associate 91 --project my/app/directory
|
|
@ -1,21 +0,0 @@
|
|||||||
# app create <name>
|
|
||||||
|
|
||||||
Use this command to create a new resin.io application.
|
|
||||||
|
|
||||||
You can specify the application type with the `--type` option.
|
|
||||||
Otherwise, an interactive dropdown will be shown for you to select from.
|
|
||||||
|
|
||||||
You can see a list of supported device types with
|
|
||||||
|
|
||||||
$ resin devices supported
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin app create MyApp
|
|
||||||
$ resin app create MyApp --type raspberry-pi
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --type, -t <type>
|
|
||||||
|
|
||||||
application type
|
|
@ -1,7 +0,0 @@
|
|||||||
# app <id>
|
|
||||||
|
|
||||||
Use this command to show detailed information for a single application.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin app 91
|
|
@ -1,13 +0,0 @@
|
|||||||
# init
|
|
||||||
|
|
||||||
Use this command to initialise a directory as a resin application.
|
|
||||||
|
|
||||||
This command performs the following steps:
|
|
||||||
- Create a resin.io application.
|
|
||||||
- Initialize the current directory as a git repository.
|
|
||||||
- Add the corresponding git remote to the application.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin init
|
|
||||||
$ resin init --project my/app/directory
|
|
@ -1,10 +0,0 @@
|
|||||||
# apps
|
|
||||||
|
|
||||||
Use this command to list all your applications.
|
|
||||||
|
|
||||||
Notice this command only shows the most important bits of information for each app.
|
|
||||||
If you want detailed information, use resin app <id> instead.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin apps
|
|
@ -1,17 +0,0 @@
|
|||||||
# app rm <id>
|
|
||||||
|
|
||||||
Use this command to remove a resin.io application.
|
|
||||||
|
|
||||||
Notice this command asks for confirmation interactively.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin app rm 91
|
|
||||||
$ resin app rm 91 --yes
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,7 +0,0 @@
|
|||||||
# app restart <id>
|
|
||||||
|
|
||||||
Use this command to restart all devices that belongs to a certain application.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin app restart 91
|
|
@ -1,22 +0,0 @@
|
|||||||
# login
|
|
||||||
|
|
||||||
Use this command to login to your resin.io account.
|
|
||||||
You need to login before you can use most of the commands this tool provides.
|
|
||||||
|
|
||||||
You can pass your credentials as `--username` and `--password` options, or you can omit the
|
|
||||||
credentials, in which case the tool will present you with an interactive login form.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin login --username <username> --password <password>
|
|
||||||
$ resin login
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --username, -u <username>
|
|
||||||
|
|
||||||
user name
|
|
||||||
|
|
||||||
### --password, -p <password>
|
|
||||||
|
|
||||||
user password
|
|
@ -1,7 +0,0 @@
|
|||||||
# logout
|
|
||||||
|
|
||||||
Use this command to logout from your resin.io account.o
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin logout
|
|
@ -1,31 +0,0 @@
|
|||||||
# signup
|
|
||||||
|
|
||||||
Use this command to signup for a resin.io account.
|
|
||||||
|
|
||||||
If signup is successful, you'll be logged in to your new user automatically.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin signup
|
|
||||||
Email: me@mycompany.com
|
|
||||||
Username: johndoe
|
|
||||||
Password: ***********
|
|
||||||
|
|
||||||
$ resin signup --email me@mycompany.com --username johndoe --password ***********
|
|
||||||
|
|
||||||
$ resin whoami
|
|
||||||
johndoe
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --email, -e <email>
|
|
||||||
|
|
||||||
user email
|
|
||||||
|
|
||||||
### --username, -u <username>
|
|
||||||
|
|
||||||
user name
|
|
||||||
|
|
||||||
### --password, -p <user password>
|
|
||||||
|
|
||||||
user password
|
|
@ -1,7 +0,0 @@
|
|||||||
# whoami
|
|
||||||
|
|
||||||
Use this command to find out the current logged in username.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin whoami
|
|
774
doc/cli.markdown
Normal file
774
doc/cli.markdown
Normal file
@ -0,0 +1,774 @@
|
|||||||
|
# Resin CLI Documentation
|
||||||
|
|
||||||
|
This tool allows you to interact with the resin.io api from the comfort of your command line.
|
||||||
|
|
||||||
|
To get started download the CLI from npm.
|
||||||
|
|
||||||
|
$ npm install resin-cli -g
|
||||||
|
|
||||||
|
Then authenticate yourself:
|
||||||
|
|
||||||
|
$ resin login
|
||||||
|
|
||||||
|
Now you have access to all the commands referenced below.
|
||||||
|
|
||||||
|
# Table of contents
|
||||||
|
|
||||||
|
- Application
|
||||||
|
|
||||||
|
- [app create <name>](#/pages/using/cli.md#app-create-60-name-62-)
|
||||||
|
- [apps](#/pages/using/cli.md#apps)
|
||||||
|
- [app <name>](#/pages/using/cli.md#app-60-name-62-)
|
||||||
|
- [app restart <name>](#/pages/using/cli.md#app-restart-60-name-62-)
|
||||||
|
- [app rm <name>](#/pages/using/cli.md#app-rm-60-name-62-)
|
||||||
|
- [app associate <name>](#/pages/using/cli.md#app-associate-60-name-62-)
|
||||||
|
- [init](#/pages/using/cli.md#init)
|
||||||
|
|
||||||
|
- Authentication
|
||||||
|
|
||||||
|
- [whoami](#/pages/using/cli.md#whoami)
|
||||||
|
- [login [token]](#/pages/using/cli.md#login-token-)
|
||||||
|
- [logout](#/pages/using/cli.md#logout)
|
||||||
|
- [signup](#/pages/using/cli.md#signup)
|
||||||
|
|
||||||
|
- Device
|
||||||
|
|
||||||
|
- [devices](#/pages/using/cli.md#devices)
|
||||||
|
- [device <name>](#/pages/using/cli.md#device-60-name-62-)
|
||||||
|
- [device rm <name>](#/pages/using/cli.md#device-rm-60-name-62-)
|
||||||
|
- [device identify <uuid>](#/pages/using/cli.md#device-identify-60-uuid-62-)
|
||||||
|
- [device rename <name> [newName]](#/pages/using/cli.md#device-rename-60-name-62-newname-)
|
||||||
|
- [devices supported](#/pages/using/cli.md#devices-supported)
|
||||||
|
- [device init [device]](#/pages/using/cli.md#device-init-device-)
|
||||||
|
|
||||||
|
- Drive
|
||||||
|
|
||||||
|
- [drives](#/pages/using/cli.md#drives)
|
||||||
|
|
||||||
|
- Environment Variables
|
||||||
|
|
||||||
|
- [envs](#/pages/using/cli.md#envs)
|
||||||
|
- [env rm <id>](#/pages/using/cli.md#env-rm-60-id-62-)
|
||||||
|
- [env add <key> [value]](#/pages/using/cli.md#env-add-60-key-62-value-)
|
||||||
|
- [env rename <id> <value>](#/pages/using/cli.md#env-rename-60-id-62-60-value-62-)
|
||||||
|
|
||||||
|
- Examples
|
||||||
|
|
||||||
|
- [examples](#/pages/using/cli.md#examples)
|
||||||
|
- [example <id>](#/pages/using/cli.md#example-60-id-62-)
|
||||||
|
- [example clone <id>](#/pages/using/cli.md#example-clone-60-id-62-)
|
||||||
|
|
||||||
|
- Help
|
||||||
|
|
||||||
|
- [help [command...]](#/pages/using/cli.md#help-command-)
|
||||||
|
|
||||||
|
- Information
|
||||||
|
|
||||||
|
- [version](#/pages/using/cli.md#version)
|
||||||
|
|
||||||
|
- Keys
|
||||||
|
|
||||||
|
- [keys](#/pages/using/cli.md#keys)
|
||||||
|
- [key <id>](#/pages/using/cli.md#key-60-id-62-)
|
||||||
|
- [key rm <id>](#/pages/using/cli.md#key-rm-60-id-62-)
|
||||||
|
- [key add <name> [path]](#/pages/using/cli.md#key-add-60-name-62-path-)
|
||||||
|
|
||||||
|
- Logs
|
||||||
|
|
||||||
|
- [logs <uuid>](#/pages/using/cli.md#logs-60-uuid-62-)
|
||||||
|
|
||||||
|
- Notes
|
||||||
|
|
||||||
|
- [note <|note>](#/pages/using/cli.md#note-60-note-62-)
|
||||||
|
|
||||||
|
- OS
|
||||||
|
|
||||||
|
- [os download <id>](#/pages/using/cli.md#os-download-60-id-62-)
|
||||||
|
- [os install <image> [device]](#/pages/using/cli.md#os-install-60-image-62-device-)
|
||||||
|
|
||||||
|
- Plugin
|
||||||
|
|
||||||
|
- [plugins](#/pages/using/cli.md#plugins)
|
||||||
|
- [plugin install <name>](#/pages/using/cli.md#plugin-install-60-name-62-)
|
||||||
|
- [plugin update <name>](#/pages/using/cli.md#plugin-update-60-name-62-)
|
||||||
|
- [plugin rm <name>](#/pages/using/cli.md#plugin-rm-60-name-62-)
|
||||||
|
|
||||||
|
- Preferences
|
||||||
|
|
||||||
|
- [preferences](#/pages/using/cli.md#preferences)
|
||||||
|
|
||||||
|
- Update
|
||||||
|
|
||||||
|
- [update](#/pages/using/cli.md#update)
|
||||||
|
|
||||||
|
# Application
|
||||||
|
|
||||||
|
## app create <name>
|
||||||
|
|
||||||
|
Use this command to create a new resin.io application.
|
||||||
|
|
||||||
|
You can specify the application type with the `--type` option.
|
||||||
|
Otherwise, an interactive dropdown will be shown for you to select from.
|
||||||
|
|
||||||
|
You can see a list of supported device types with
|
||||||
|
|
||||||
|
$ resin devices supported
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin app create MyApp
|
||||||
|
$ resin app create MyApp --type raspberry-pi
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --type, -t <type>
|
||||||
|
|
||||||
|
application type
|
||||||
|
|
||||||
|
## apps
|
||||||
|
|
||||||
|
Use this command to list all your applications.
|
||||||
|
|
||||||
|
Notice this command only shows the most important bits of information for each app.
|
||||||
|
If you want detailed information, use resin app <name> instead.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin apps
|
||||||
|
|
||||||
|
## app <name>
|
||||||
|
|
||||||
|
Use this command to show detailed information for a single application.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin app MyApp
|
||||||
|
|
||||||
|
## app restart <name>
|
||||||
|
|
||||||
|
Use this command to restart all devices that belongs to a certain application.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin app restart MyApp
|
||||||
|
|
||||||
|
## app rm <name>
|
||||||
|
|
||||||
|
Use this command to remove a resin.io application.
|
||||||
|
|
||||||
|
Notice this command asks for confirmation interactively.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin app rm MyApp
|
||||||
|
$ resin app rm MyApp --yes
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
## app associate <name>
|
||||||
|
|
||||||
|
Use this command to associate a project directory with a resin application.
|
||||||
|
|
||||||
|
This command adds a 'resin' git remote to the directory and runs git init if necessary.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin app associate MyApp
|
||||||
|
$ resin app associate MyApp --project my/app/directory
|
||||||
|
|
||||||
|
## init
|
||||||
|
|
||||||
|
Use this command to initialise a directory as a resin application.
|
||||||
|
|
||||||
|
This command performs the following steps:
|
||||||
|
- Create a resin.io application.
|
||||||
|
- Initialize the current directory as a git repository.
|
||||||
|
- Add the corresponding git remote to the application.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin init
|
||||||
|
$ resin init --project my/app/directory
|
||||||
|
|
||||||
|
# Authentication
|
||||||
|
|
||||||
|
## whoami
|
||||||
|
|
||||||
|
Use this command to find out the current logged in username.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin whoami
|
||||||
|
|
||||||
|
## login [token]
|
||||||
|
|
||||||
|
Use this command to login to your resin.io account.
|
||||||
|
|
||||||
|
To login, you need your token, which is accesible from the preferences page:
|
||||||
|
|
||||||
|
https://staging.resin.io/preferences
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin login
|
||||||
|
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||||
|
|
||||||
|
## logout
|
||||||
|
|
||||||
|
Use this command to logout from your resin.io account.o
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin logout
|
||||||
|
|
||||||
|
## signup
|
||||||
|
|
||||||
|
Use this command to signup for a resin.io account.
|
||||||
|
|
||||||
|
If signup is successful, you'll be logged in to your new user automatically.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin signup
|
||||||
|
Email: me@mycompany.com
|
||||||
|
Username: johndoe
|
||||||
|
Password: ***********
|
||||||
|
|
||||||
|
$ resin signup --email me@mycompany.com --username johndoe --password ***********
|
||||||
|
|
||||||
|
$ resin whoami
|
||||||
|
johndoe
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --email, -e <email>
|
||||||
|
|
||||||
|
user email
|
||||||
|
|
||||||
|
#### --username, -u <username>
|
||||||
|
|
||||||
|
user name
|
||||||
|
|
||||||
|
#### --password, -p <user password>
|
||||||
|
|
||||||
|
user password
|
||||||
|
|
||||||
|
# Device
|
||||||
|
|
||||||
|
## devices
|
||||||
|
|
||||||
|
Use this command to list all devices that belong to a certain application.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin devices --application MyApp
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --application, --a,app, --a,app <application>
|
||||||
|
|
||||||
|
application name
|
||||||
|
|
||||||
|
## device <name>
|
||||||
|
|
||||||
|
Use this command to show information about a single device.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin device MyDevice
|
||||||
|
|
||||||
|
## device rm <name>
|
||||||
|
|
||||||
|
Use this command to remove a device from resin.io.
|
||||||
|
|
||||||
|
Notice this command asks for confirmation interactively.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin device rm MyDevice
|
||||||
|
$ resin device rm MyDevice --yes
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
## device identify <uuid>
|
||||||
|
|
||||||
|
Use this command to identify a device.
|
||||||
|
|
||||||
|
In the Raspberry Pi, the ACT led is blinked several times.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
||||||
|
|
||||||
|
## device rename <name> [newName]
|
||||||
|
|
||||||
|
Use this command to rename a device.
|
||||||
|
|
||||||
|
If you omit the name, you'll get asked for it interactively.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin device rename MyDevice MyPi
|
||||||
|
$ resin device rename MyDevice
|
||||||
|
|
||||||
|
## devices supported
|
||||||
|
|
||||||
|
Use this command to get the list of all supported devices
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin devices supported
|
||||||
|
|
||||||
|
## device init [device]
|
||||||
|
|
||||||
|
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.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||||
|
|
||||||
|
You may have to unmount the device before attempting this operation.
|
||||||
|
|
||||||
|
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 91
|
||||||
|
$ resin device init --application 91 --network ethernet
|
||||||
|
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --application, --a,app, --a,app <application>
|
||||||
|
|
||||||
|
application name
|
||||||
|
|
||||||
|
#### --network, -n <network>
|
||||||
|
|
||||||
|
network type
|
||||||
|
|
||||||
|
#### --ssid, -s <ssid>
|
||||||
|
|
||||||
|
wifi ssid, if network is wifi
|
||||||
|
|
||||||
|
#### --key, -k <key>
|
||||||
|
|
||||||
|
wifi key, if network is wifi
|
||||||
|
|
||||||
|
# Drive
|
||||||
|
|
||||||
|
## drives
|
||||||
|
|
||||||
|
Use this command to list all drives that are connected to your machine.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin drives
|
||||||
|
|
||||||
|
# Environment Variables
|
||||||
|
|
||||||
|
## envs
|
||||||
|
|
||||||
|
Use this command to list all environment variables for a particular application.
|
||||||
|
Notice we will support per-device environment variables soon.
|
||||||
|
|
||||||
|
This command lists all custom environment variables set on the devices running
|
||||||
|
the application. If you want to see all environment variables, including private
|
||||||
|
ones used by resin, use the verbose option.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ resin envs --application 91
|
||||||
|
$ resin envs --application 91 --verbose
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --application, --a,app, --a,app <application>
|
||||||
|
|
||||||
|
application name
|
||||||
|
|
||||||
|
#### --verbose, -v
|
||||||
|
|
||||||
|
show private environment variables
|
||||||
|
|
||||||
|
## env rm <id>
|
||||||
|
|
||||||
|
Use this command to remove an environment variable from an application.
|
||||||
|
|
||||||
|
Don't remove resin specific variables, as things might not work as expected.
|
||||||
|
|
||||||
|
Notice this command asks for confirmation interactively.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin env rm 215
|
||||||
|
$ resin env rm 215 --yes
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
## env add <key> [value]
|
||||||
|
|
||||||
|
Use this command to add an enviroment variable to an application.
|
||||||
|
|
||||||
|
You need to pass the `--application` option.
|
||||||
|
|
||||||
|
If value is omitted, the tool will attempt to use the variable's value
|
||||||
|
as defined in your host machine.
|
||||||
|
|
||||||
|
If the value is grabbed from the environment, a warning message will be printed.
|
||||||
|
Use `--quiet` to remove it.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin env add EDITOR vim -a 91
|
||||||
|
$ resin env add TERM -a 91
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --application, --a,app, --a,app <application>
|
||||||
|
|
||||||
|
application name
|
||||||
|
|
||||||
|
## env rename <id> <value>
|
||||||
|
|
||||||
|
Use this command to rename an enviroment variable from an application.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin env rename 376 emacs
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
|
||||||
|
## examples
|
||||||
|
|
||||||
|
Use this command to list available example applications from resin.io
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ resin examples
|
||||||
|
|
||||||
|
## example <id>
|
||||||
|
|
||||||
|
Use this command to show information of a single example application
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ resin example 3
|
||||||
|
|
||||||
|
## example clone <id>
|
||||||
|
|
||||||
|
Use this command to clone an example application to the current directory
|
||||||
|
|
||||||
|
This command outputs information about the cloning process.
|
||||||
|
Use `--quiet` to remove that output.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ resin example clone 3
|
||||||
|
|
||||||
|
# Help
|
||||||
|
|
||||||
|
## help [command...]
|
||||||
|
|
||||||
|
Get detailed help for an specific command.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin help apps
|
||||||
|
$ resin help os download
|
||||||
|
|
||||||
|
# Information
|
||||||
|
|
||||||
|
## version
|
||||||
|
|
||||||
|
Display the Resin CLI version.
|
||||||
|
|
||||||
|
# Keys
|
||||||
|
|
||||||
|
## keys
|
||||||
|
|
||||||
|
Use this command to list all your SSH keys.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin keys
|
||||||
|
|
||||||
|
## key <id>
|
||||||
|
|
||||||
|
Use this command to show information about a single SSH key.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin key 17
|
||||||
|
|
||||||
|
## key rm <id>
|
||||||
|
|
||||||
|
Use this command to remove a SSH key from resin.io.
|
||||||
|
|
||||||
|
Notice this command asks for confirmation interactively.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin key rm 17
|
||||||
|
$ resin key rm 17 --yes
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
## key add <name> [path]
|
||||||
|
|
||||||
|
Use this command to associate a new SSH key with your account.
|
||||||
|
|
||||||
|
If `path` is omitted, the command will attempt
|
||||||
|
to read the SSH key from stdin.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin key add Main ~/.ssh/id_rsa.pub
|
||||||
|
$ cat ~/.ssh/id_rsa.pub | resin key add Main
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
|
||||||
|
## logs <uuid>
|
||||||
|
|
||||||
|
Use this command to show logs for a specific device.
|
||||||
|
|
||||||
|
By default, the command prints all log messages and exit.
|
||||||
|
|
||||||
|
To limit the output to the n last lines, use the `--num` option along with a number.
|
||||||
|
This is similar to doing `resin logs <uuid> | tail -n X`.
|
||||||
|
|
||||||
|
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
||||||
|
|
||||||
|
Note that for now you need to provide the whole UUID for this command to work correctly,
|
||||||
|
and the tool won't notice if you're using an invalid UUID.
|
||||||
|
|
||||||
|
This is due to some technical limitations that we plan to address soon.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
||||||
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --num 20
|
||||||
|
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --tail
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --num, -n <num>
|
||||||
|
|
||||||
|
number of lines to display
|
||||||
|
|
||||||
|
#### --tail, -t
|
||||||
|
|
||||||
|
continuously stream output
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
|
||||||
|
## note <|note>
|
||||||
|
|
||||||
|
Use this command to set or update a device note.
|
||||||
|
|
||||||
|
If note command isn't passed, the tool attempts to read from `stdin`.
|
||||||
|
|
||||||
|
To view the notes, use $ resin device <name>.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin note "My useful note" --device MyDevice
|
||||||
|
$ cat note.txt | resin note --device MyDevice
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --device, --d,dev, --d,dev <device>
|
||||||
|
|
||||||
|
device name
|
||||||
|
|
||||||
|
# OS
|
||||||
|
|
||||||
|
## os download <id>
|
||||||
|
|
||||||
|
Use this command to download the device OS configured to a specific network.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Alternatively, you can omit all kind of network configuration options to configure interactively.
|
||||||
|
|
||||||
|
You have to specify an output location with the `--output` option.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --network, -n <network>
|
||||||
|
|
||||||
|
network type
|
||||||
|
|
||||||
|
#### --ssid, -s <ssid>
|
||||||
|
|
||||||
|
wifi ssid, if network is wifi
|
||||||
|
|
||||||
|
#### --key, -k <key>
|
||||||
|
|
||||||
|
wifi key, if network is wifi
|
||||||
|
|
||||||
|
#### --output, -o <output>
|
||||||
|
|
||||||
|
output file
|
||||||
|
|
||||||
|
## os install <image> [device]
|
||||||
|
|
||||||
|
Use this command to write an operating system image to a device.
|
||||||
|
|
||||||
|
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.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||||
|
|
||||||
|
You may have to unmount the device before attempting this operation.
|
||||||
|
|
||||||
|
See the `drives` command to get a list of all connected devices to your machine and their respective ids.
|
||||||
|
|
||||||
|
In Mac OS X:
|
||||||
|
|
||||||
|
$ sudo diskutil unmountDisk /dev/xxx
|
||||||
|
|
||||||
|
In GNU/Linux:
|
||||||
|
|
||||||
|
$ sudo umount /dev/xxx
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin os install rpi.iso /dev/disk2
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
# Plugin
|
||||||
|
|
||||||
|
## plugins
|
||||||
|
|
||||||
|
Use this command to list all the installed resin plugins.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin plugins
|
||||||
|
|
||||||
|
## plugin install <name>
|
||||||
|
|
||||||
|
Use this command to install a resin plugin
|
||||||
|
|
||||||
|
Use `--quiet` to prevent information logging.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin plugin install hello
|
||||||
|
|
||||||
|
## plugin update <name>
|
||||||
|
|
||||||
|
Use this command to update a resin plugin
|
||||||
|
|
||||||
|
Use `--quiet` to prevent information logging.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin plugin update hello
|
||||||
|
|
||||||
|
## plugin rm <name>
|
||||||
|
|
||||||
|
Use this command to remove a resin.io plugin.
|
||||||
|
|
||||||
|
Notice this command asks for confirmation interactively.
|
||||||
|
You can avoid this by passing the `--yes` boolean option.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin plugin rm hello
|
||||||
|
$ resin plugin rm hello --yes
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --yes, -y
|
||||||
|
|
||||||
|
confirm non interactively
|
||||||
|
|
||||||
|
# Preferences
|
||||||
|
|
||||||
|
## preferences
|
||||||
|
|
||||||
|
Use this command to open the preferences form.
|
||||||
|
|
||||||
|
In the future, we will allow changing all preferences directly from the terminal.
|
||||||
|
For now, we open your default web browser and point it to the web based preferences form.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin preferences
|
||||||
|
|
||||||
|
# Update
|
||||||
|
|
||||||
|
## update
|
||||||
|
|
||||||
|
Use this command to update the Resin CLI
|
||||||
|
|
||||||
|
This command outputs information about the update process.
|
||||||
|
Use `--quiet` to remove that output.
|
||||||
|
|
||||||
|
The Resin CLI checks for updates once per day.
|
||||||
|
|
||||||
|
Major updates require a manual update with this update command,
|
||||||
|
while minor updates are applied automatically.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin update
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
# device identify <uuid>
|
|
||||||
|
|
||||||
Use this command to identify a device.
|
|
||||||
|
|
||||||
In the Raspberry Pi, the ACT led is blinked several times.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
|
@ -1,7 +0,0 @@
|
|||||||
# device <id>
|
|
||||||
|
|
||||||
Use this command to show information about a single device.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin device 317
|
|
@ -1,49 +0,0 @@
|
|||||||
# device init [device]
|
|
||||||
|
|
||||||
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.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
|
||||||
|
|
||||||
You may have to unmount the device before attempting this operation.
|
|
||||||
|
|
||||||
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 --application 91
|
|
||||||
$ resin device init --application 91 --network ethernet
|
|
||||||
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --application, --a,app, --a,app <application>
|
|
||||||
|
|
||||||
application id
|
|
||||||
|
|
||||||
### --network, -n <network>
|
|
||||||
|
|
||||||
network type
|
|
||||||
|
|
||||||
### --ssid, -s <ssid>
|
|
||||||
|
|
||||||
wifi ssid, if network is wifi
|
|
||||||
|
|
||||||
### --key, -k <key>
|
|
||||||
|
|
||||||
wifi key, if network is wifi
|
|
@ -1,13 +0,0 @@
|
|||||||
# devices
|
|
||||||
|
|
||||||
Use this command to list all devices that belong to a certain application.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin devices --application 91
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --application, --a,app, --a,app <application>
|
|
||||||
|
|
||||||
application id
|
|
@ -1,17 +0,0 @@
|
|||||||
# device rm <id>
|
|
||||||
|
|
||||||
Use this command to remove a device from resin.io.
|
|
||||||
|
|
||||||
Notice this command asks for confirmation interactively.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin device rm 317
|
|
||||||
$ resin device rm 317 --yes
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,10 +0,0 @@
|
|||||||
# device rename <id> [name]
|
|
||||||
|
|
||||||
Use this command to rename a device.
|
|
||||||
|
|
||||||
If you omit the name, you'll get asked for it interactively.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin device rename 317 MyPi
|
|
||||||
$ resin device rename 317
|
|
@ -1,7 +0,0 @@
|
|||||||
# devices supported
|
|
||||||
|
|
||||||
Use this command to get the list of all supported devices
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin devices supported
|
|
@ -1,7 +0,0 @@
|
|||||||
# drives
|
|
||||||
|
|
||||||
Use this command to list all drives that are connected to your machine.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin drives
|
|
@ -1,22 +0,0 @@
|
|||||||
# env add <key> [value]
|
|
||||||
|
|
||||||
Use this command to add an enviroment variable to an application.
|
|
||||||
|
|
||||||
You need to pass the `--application` option.
|
|
||||||
|
|
||||||
If value is omitted, the tool will attempt to use the variable's value
|
|
||||||
as defined in your host machine.
|
|
||||||
|
|
||||||
If the value is grabbed from the environment, a warning message will be printed.
|
|
||||||
Use `--quiet` to remove it.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin env add EDITOR vim -a 91
|
|
||||||
$ resin env add TERM -a 91
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --application, --a,app, --a,app <application>
|
|
||||||
|
|
||||||
application id
|
|
@ -1,23 +0,0 @@
|
|||||||
# envs
|
|
||||||
|
|
||||||
Use this command to list all environment variables for a particular application.
|
|
||||||
Notice we will support per-device environment variables soon.
|
|
||||||
|
|
||||||
This command lists all custom environment variables set on the devices running
|
|
||||||
the application. If you want to see all environment variables, including private
|
|
||||||
ones used by resin, use the verbose option.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
$ resin envs --application 91
|
|
||||||
$ resin envs --application 91 --verbose
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --application, --a,app, --a,app <application>
|
|
||||||
|
|
||||||
application id
|
|
||||||
|
|
||||||
### --verbose, -v
|
|
||||||
|
|
||||||
show private environment variables
|
|
@ -1,19 +0,0 @@
|
|||||||
# env rm <id>
|
|
||||||
|
|
||||||
Use this command to remove an environment variable from an application.
|
|
||||||
|
|
||||||
Don't remove resin specific variables, as things might not work as expected.
|
|
||||||
|
|
||||||
Notice this command asks for confirmation interactively.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin env rm 215
|
|
||||||
$ resin env rm 215 --yes
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,7 +0,0 @@
|
|||||||
# env rename <id> <value>
|
|
||||||
|
|
||||||
Use this command to rename an enviroment variable from an application.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin env rename 376 emacs
|
|
@ -1,10 +0,0 @@
|
|||||||
# example clone <id>
|
|
||||||
|
|
||||||
Use this command to clone an example application to the current directory
|
|
||||||
|
|
||||||
This command outputs information about the cloning process.
|
|
||||||
Use `--quiet` to remove that output.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
$ resin example clone 3
|
|
@ -1,7 +0,0 @@
|
|||||||
# example <id>
|
|
||||||
|
|
||||||
Use this command to show information of a single example application
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
$ resin example 3
|
|
@ -1,7 +0,0 @@
|
|||||||
# examples
|
|
||||||
|
|
||||||
Use this command to list available example applications from resin.io
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
$ resin examples
|
|
@ -1,8 +0,0 @@
|
|||||||
# help [command...]
|
|
||||||
|
|
||||||
Get detailed help for an specific command.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin help apps
|
|
||||||
$ resin help os download
|
|
@ -1,3 +0,0 @@
|
|||||||
# version
|
|
||||||
|
|
||||||
Display the Resin CLI, as well as the bundled NodeJS version.
|
|
@ -1,11 +0,0 @@
|
|||||||
# key add <name> [path]
|
|
||||||
|
|
||||||
Use this command to associate a new SSH key with your account.
|
|
||||||
|
|
||||||
If `path` is omitted, the command will attempt
|
|
||||||
to read the SSH key from stdin.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin key add Main ~/.ssh/id_rsa.pub
|
|
||||||
$ cat ~/.ssh/id_rsa.pub | resin key add Main
|
|
@ -1,7 +0,0 @@
|
|||||||
# key <id>
|
|
||||||
|
|
||||||
Use this command to show information about a single SSH key.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin key 17
|
|
@ -1,7 +0,0 @@
|
|||||||
# keys
|
|
||||||
|
|
||||||
Use this command to list all your SSH keys.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin keys
|
|
@ -1,17 +0,0 @@
|
|||||||
# key rm <id>
|
|
||||||
|
|
||||||
Use this command to remove a SSH key from resin.io.
|
|
||||||
|
|
||||||
Notice this command asks for confirmation interactively.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin key rm 17
|
|
||||||
$ resin key rm 17 --yes
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,18 +0,0 @@
|
|||||||
# note <|note>
|
|
||||||
|
|
||||||
Use this command to set or update a device note.
|
|
||||||
|
|
||||||
If note command isn't passed, the tool attempts to read from `stdin`.
|
|
||||||
|
|
||||||
To view the notes, use $ resin device <id>.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin note "My useful note" --device 317
|
|
||||||
$ cat note.txt | resin note --device 317
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --device, --d,dev, --d,dev <device>
|
|
||||||
|
|
||||||
device id
|
|
@ -1,39 +0,0 @@
|
|||||||
# os download <id>
|
|
||||||
|
|
||||||
Use this command to download the device OS configured to a specific network.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Alternatively, you can omit all kind of network configuration options to configure interactively.
|
|
||||||
|
|
||||||
You have to specify an output location with the `--output` option.
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --network, -n <network>
|
|
||||||
|
|
||||||
network type
|
|
||||||
|
|
||||||
### --ssid, -s <ssid>
|
|
||||||
|
|
||||||
wifi ssid, if network is wifi
|
|
||||||
|
|
||||||
### --key, -k <key>
|
|
||||||
|
|
||||||
wifi key, if network is wifi
|
|
||||||
|
|
||||||
### --output, -o <output>
|
|
||||||
|
|
||||||
output file
|
|
@ -1,34 +0,0 @@
|
|||||||
# os install <image> [device]
|
|
||||||
|
|
||||||
Use this command to write an operating system image to a device.
|
|
||||||
|
|
||||||
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.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
|
||||||
|
|
||||||
You may have to unmount the device before attempting this operation.
|
|
||||||
|
|
||||||
See the `drives` command to get a list of all connected devices to your machine and their respective ids.
|
|
||||||
|
|
||||||
In Mac OS X:
|
|
||||||
|
|
||||||
$ sudo diskutil unmountDisk /dev/xxx
|
|
||||||
|
|
||||||
In GNU/Linux:
|
|
||||||
|
|
||||||
$ sudo umount /dev/xxx
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin os install rpi.iso /dev/disk2
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,9 +0,0 @@
|
|||||||
# plugin install <name>
|
|
||||||
|
|
||||||
Use this command to install a resin plugin
|
|
||||||
|
|
||||||
Use `--quiet` to prevent information logging.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin plugin install hello
|
|
@ -1,7 +0,0 @@
|
|||||||
# plugins
|
|
||||||
|
|
||||||
Use this command to list all the installed resin plugins.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin plugins
|
|
@ -1,17 +0,0 @@
|
|||||||
# plugin rm <name>
|
|
||||||
|
|
||||||
Use this command to remove a resin.io plugin.
|
|
||||||
|
|
||||||
Notice this command asks for confirmation interactively.
|
|
||||||
You can avoid this by passing the `--yes` boolean option.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin plugin rm hello
|
|
||||||
$ resin plugin rm hello --yes
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
### --yes, -y
|
|
||||||
|
|
||||||
confirm non interactively
|
|
@ -1,9 +0,0 @@
|
|||||||
# plugin update <name>
|
|
||||||
|
|
||||||
Use this command to update a resin plugin
|
|
||||||
|
|
||||||
Use `--quiet` to prevent information logging.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin plugin update hello
|
|
@ -1,10 +0,0 @@
|
|||||||
# preferences
|
|
||||||
|
|
||||||
Use this command to open the preferences form.
|
|
||||||
|
|
||||||
In the future, we will allow changing all preferences directly from the terminal.
|
|
||||||
For now, we open your default web browser and point it to the web based preferences form.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin preferences
|
|
@ -1,15 +0,0 @@
|
|||||||
# update
|
|
||||||
|
|
||||||
Use this command to update the Resin CLI
|
|
||||||
|
|
||||||
This command outputs information about the update process.
|
|
||||||
Use `--quiet` to remove that output.
|
|
||||||
|
|
||||||
The Resin CLI checks for updates once per day.
|
|
||||||
|
|
||||||
Major updates require a manual update with this update command,
|
|
||||||
while minor updates are applied automatically.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ resin update
|
|
@ -1,20 +0,0 @@
|
|||||||
mkdirp = require('mkdirp')
|
|
||||||
fs = require('fs')
|
|
||||||
path = require('path')
|
|
||||||
capitano = require('capitano')
|
|
||||||
markdown = require('./markdown')
|
|
||||||
|
|
||||||
capitano.command
|
|
||||||
signature: 'markdown <file> <output>'
|
|
||||||
description: 'file to markdown'
|
|
||||||
action: (params, options, done) ->
|
|
||||||
mkdirp.sync(params.output)
|
|
||||||
action = require(params.file)
|
|
||||||
|
|
||||||
for actionName, actionCommand of action
|
|
||||||
output = path.join(params.output, "#{actionName}.md")
|
|
||||||
fs.writeFileSync(output, markdown.command(actionCommand))
|
|
||||||
|
|
||||||
return done()
|
|
||||||
|
|
||||||
capitano.run(process.argv)
|
|
@ -1,23 +0,0 @@
|
|||||||
_ = require('lodash')
|
|
||||||
utils = require('./utils')
|
|
||||||
|
|
||||||
exports.option = (option) ->
|
|
||||||
result = utils.parseSignature(option)
|
|
||||||
|
|
||||||
exports.command = (command) ->
|
|
||||||
result = """
|
|
||||||
# #{command.signature}
|
|
||||||
|
|
||||||
#{command.help}\n
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not _.isEmpty(command.options)
|
|
||||||
result += '\n## Options'
|
|
||||||
|
|
||||||
for option in command.options
|
|
||||||
result += """
|
|
||||||
\n\n### #{utils.parseSignature(option)}
|
|
||||||
|
|
||||||
#{option.description}
|
|
||||||
"""
|
|
||||||
return result
|
|
45
extras/capitanodoc/index.coffee
Normal file
45
extras/capitanodoc/index.coffee
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
capitanodoc = require('../../capitanodoc.json')
|
||||||
|
markdown = require('./markdown')
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
result.title = capitanodoc.title
|
||||||
|
result.introduction = capitanodoc.introduction
|
||||||
|
result.categories = []
|
||||||
|
|
||||||
|
for commandCategory in capitanodoc.categories
|
||||||
|
category = {}
|
||||||
|
category.title = commandCategory.title
|
||||||
|
category.commands = []
|
||||||
|
|
||||||
|
for file in commandCategory.files
|
||||||
|
actions = require(file)
|
||||||
|
|
||||||
|
for actionName, actionCommand of actions
|
||||||
|
category.commands.push(_.omit(actionCommand, 'action'))
|
||||||
|
|
||||||
|
result.categories.push(category)
|
||||||
|
|
||||||
|
result.toc = _.cloneDeep(result.categories)
|
||||||
|
result.toc = _.map result.toc, (category) ->
|
||||||
|
category.commands = _.map category.commands, (command) ->
|
||||||
|
return {
|
||||||
|
signature: command.signature
|
||||||
|
|
||||||
|
# TODO: Make anchor prefix a configurable setting
|
||||||
|
# in capitanodoc.json
|
||||||
|
anchor: '#/pages/using/cli.md#' + command.signature
|
||||||
|
.replace(/\s/g,'-')
|
||||||
|
.replace(/</g, '60-')
|
||||||
|
.replace(/>/g, '-62-')
|
||||||
|
.replace(/\[/g, '')
|
||||||
|
.replace(/\]/g, '-')
|
||||||
|
.replace(/--/g, '-')
|
||||||
|
.replace(/\.\.\./g, '')
|
||||||
|
.replace(/\|/g, '')
|
||||||
|
.toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
return category
|
||||||
|
|
||||||
|
console.log(markdown.display(result))
|
66
extras/capitanodoc/markdown.coffee
Normal file
66
extras/capitanodoc/markdown.coffee
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
ent = require('ent')
|
||||||
|
utils = require('./utils')
|
||||||
|
|
||||||
|
exports.command = (command) ->
|
||||||
|
result = """
|
||||||
|
## #{ent.encode(command.signature)}
|
||||||
|
|
||||||
|
#{command.help}\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not _.isEmpty(command.options)
|
||||||
|
result += '\n### Options'
|
||||||
|
|
||||||
|
for option in command.options
|
||||||
|
result += """
|
||||||
|
\n\n#### #{utils.parseSignature(option)}
|
||||||
|
|
||||||
|
#{option.description}
|
||||||
|
"""
|
||||||
|
|
||||||
|
result += '\n'
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
exports.category = (category) ->
|
||||||
|
result = """
|
||||||
|
# #{category.title}\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
for command in category.commands
|
||||||
|
result += '\n' + exports.command(command)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
exports.toc = (toc) ->
|
||||||
|
result = '''
|
||||||
|
# Table of contents\n
|
||||||
|
'''
|
||||||
|
|
||||||
|
for category in toc
|
||||||
|
|
||||||
|
result += """
|
||||||
|
\n- #{category.title}\n\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
for command in category.commands
|
||||||
|
result += """
|
||||||
|
\t- [#{ent.encode(command.signature)}](#{command.anchor})\n
|
||||||
|
"""
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
exports.display = (doc) ->
|
||||||
|
result = """
|
||||||
|
# #{doc.title}
|
||||||
|
|
||||||
|
#{doc.introduction}
|
||||||
|
|
||||||
|
#{exports.toc(doc.toc)}
|
||||||
|
"""
|
||||||
|
|
||||||
|
for category in doc.categories
|
||||||
|
result += '\n' + exports.category(category)
|
||||||
|
|
||||||
|
return result
|
@ -1,4 +1,5 @@
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
|
ent = require('ent')
|
||||||
|
|
||||||
exports.getOptionPrefix = (signature) ->
|
exports.getOptionPrefix = (signature) ->
|
||||||
if signature.length > 1
|
if signature.length > 1
|
||||||
@ -22,4 +23,4 @@ exports.parseSignature = (option) ->
|
|||||||
if option.parameter?
|
if option.parameter?
|
||||||
result += " <#{option.parameter}>"
|
result += " <#{option.parameter}>"
|
||||||
|
|
||||||
return result
|
return ent.encode(result)
|
@ -55,7 +55,7 @@ exports.list =
|
|||||||
Use this command to list all your applications.
|
Use this command to list all your applications.
|
||||||
|
|
||||||
Notice this command only shows the most important bits of information for each app.
|
Notice this command only shows the most important bits of information for each app.
|
||||||
If you want detailed information, use resin app <id> instead.
|
If you want detailed information, use resin app <name> instead.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -75,18 +75,18 @@ exports.list =
|
|||||||
return done()
|
return done()
|
||||||
|
|
||||||
exports.info =
|
exports.info =
|
||||||
signature: 'app <id>'
|
signature: 'app <name>'
|
||||||
description: 'list a single application'
|
description: 'list a single application'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to show detailed information for a single application.
|
Use this command to show detailed information for a single application.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin app 91
|
$ resin app MyApp
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.application.get params.id, (error, application) ->
|
resin.models.application.get params.name, (error, application) ->
|
||||||
return done(error) if error?
|
return done(error) if error?
|
||||||
console.log visuals.widgets.table.vertical application, [
|
console.log visuals.widgets.table.vertical application, [
|
||||||
'id'
|
'id'
|
||||||
@ -98,21 +98,21 @@ exports.info =
|
|||||||
return done()
|
return done()
|
||||||
|
|
||||||
exports.restart =
|
exports.restart =
|
||||||
signature: 'app restart <id>'
|
signature: 'app restart <name>'
|
||||||
description: 'restart an application'
|
description: 'restart an application'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to restart all devices that belongs to a certain application.
|
Use this command to restart all devices that belongs to a certain application.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin app restart 91
|
$ resin app restart MyApp
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.application.restart(params.id, done)
|
resin.models.application.restart(params.name, done)
|
||||||
|
|
||||||
exports.remove =
|
exports.remove =
|
||||||
signature: 'app rm <id>'
|
signature: 'app rm <name>'
|
||||||
description: 'remove an application'
|
description: 'remove an application'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to remove a resin.io application.
|
Use this command to remove a resin.io application.
|
||||||
@ -122,18 +122,18 @@ exports.remove =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin app rm 91
|
$ resin app rm MyApp
|
||||||
$ resin app rm 91 --yes
|
$ resin app rm MyApp --yes
|
||||||
'''
|
'''
|
||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
visuals.patterns.remove 'application', options.yes, (callback) ->
|
visuals.patterns.remove 'application', options.yes, (callback) ->
|
||||||
resin.models.application.remove(params.id, callback)
|
resin.models.application.remove(params.name, callback)
|
||||||
, done
|
, done
|
||||||
|
|
||||||
exports.associate =
|
exports.associate =
|
||||||
signature: 'app associate <id>'
|
signature: 'app associate <name>'
|
||||||
description: 'associate a resin project'
|
description: 'associate a resin project'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to associate a project directory with a resin application.
|
Use this command to associate a project directory with a resin application.
|
||||||
@ -142,8 +142,8 @@ exports.associate =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin app associate 91
|
$ resin app associate MyApp
|
||||||
$ resin app associate 91 --project my/app/directory
|
$ resin app associate MyApp --project my/app/directory
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
@ -155,7 +155,7 @@ exports.associate =
|
|||||||
vcs.initialize(currentDirectory, callback)
|
vcs.initialize(currentDirectory, callback)
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
resin.models.application.get(params.id, callback)
|
resin.models.application.get(params.name, callback)
|
||||||
|
|
||||||
(application, callback) ->
|
(application, callback) ->
|
||||||
vcs.addRemote(currentDirectory, application.git_repository, callback)
|
vcs.addRemote(currentDirectory, application.git_repository, callback)
|
||||||
@ -193,9 +193,14 @@ exports.init =
|
|||||||
visuals.widgets.ask('What is the name of your application?', currentDirectoryBasename, callback)
|
visuals.widgets.ask('What is the name of your application?', currentDirectoryBasename, callback)
|
||||||
|
|
||||||
(applicationName, callback) ->
|
(applicationName, callback) ->
|
||||||
exports.create.action(name: applicationName, options, callback)
|
|
||||||
|
|
||||||
(applicationId, callback) ->
|
# TODO: Make resin.models.application.create return
|
||||||
exports.associate.action(id: applicationId, options, callback)
|
# the whole application instead of just the id
|
||||||
|
exports.create.action name: applicationName, options, (error) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
return callback(null, applicationName)
|
||||||
|
|
||||||
|
(applicationName, callback) ->
|
||||||
|
exports.associate.action(name: applicationName, options, callback)
|
||||||
|
|
||||||
], done)
|
], done)
|
||||||
|
@ -1,62 +1,73 @@
|
|||||||
|
open = require('open')
|
||||||
_ = require('lodash-contrib')
|
_ = require('lodash-contrib')
|
||||||
url = require('url')
|
url = require('url')
|
||||||
async = require('async')
|
async = require('async')
|
||||||
resin = require('resin-sdk')
|
resin = require('resin-sdk')
|
||||||
|
settings = require('resin-settings-client')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
|
|
||||||
exports.login =
|
exports.whoami =
|
||||||
signature: 'login'
|
signature: 'whoami'
|
||||||
description: 'login to resin.io'
|
description: 'whoami'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to login to your resin.io account.
|
Use this command to get the logged in user name.
|
||||||
You need to login before you can use most of the commands this tool provides.
|
|
||||||
|
|
||||||
You can pass your credentials as `--username` and `--password` options, or you can omit the
|
|
||||||
credentials, in which case the tool will present you with an interactive login form.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin login --username <username> --password <password>
|
$ resin whoami
|
||||||
$ resin login
|
|
||||||
'''
|
'''
|
||||||
options: [
|
permission: 'user'
|
||||||
{
|
action: (params, options, done) ->
|
||||||
signature: 'username'
|
resin.auth.whoami (error, username) ->
|
||||||
parameter: 'username'
|
return done(error) if error?
|
||||||
description: 'user name'
|
console.log(username)
|
||||||
alias: 'u'
|
return done()
|
||||||
}
|
|
||||||
{
|
TOKEN_URL = url.resolve(settings.get('remoteUrl'), '/preferences')
|
||||||
signature: 'password'
|
|
||||||
parameter: 'password'
|
exports.login =
|
||||||
description: 'user password'
|
signature: 'login [token]'
|
||||||
alias: 'p'
|
description: 'login to resin.io'
|
||||||
}
|
help: """
|
||||||
]
|
Use this command to login to your resin.io account.
|
||||||
|
|
||||||
|
To login, you need your token, which is accesible from the preferences page:
|
||||||
|
|
||||||
|
#{TOKEN_URL}
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin login
|
||||||
|
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||||
|
"""
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
|
|
||||||
hasOptionCredentials = not _.isEmpty(options)
|
console.info """
|
||||||
|
To login to the Resin CLI, you need your unique token, which is accesible from
|
||||||
|
the preferences page at #{TOKEN_URL}
|
||||||
|
|
||||||
if hasOptionCredentials
|
Attempting to open a browser at that location...
|
||||||
|
"""
|
||||||
|
|
||||||
if not options.username
|
async.waterfall([
|
||||||
return done(new Error('Missing username'))
|
|
||||||
|
|
||||||
if not options.password
|
|
||||||
return done(new Error('Missing password'))
|
|
||||||
|
|
||||||
async.waterfall [
|
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
if hasOptionCredentials
|
open TOKEN_URL, (error) ->
|
||||||
return callback(null, options)
|
if error?
|
||||||
else
|
console.error """
|
||||||
return visuals.widgets.login(callback)
|
Unable to open a web browser in the current environment.
|
||||||
|
Please visit #{TOKEN_URL} manually.
|
||||||
|
"""
|
||||||
|
return callback()
|
||||||
|
|
||||||
(credentials, callback) ->
|
(callback) ->
|
||||||
resin.auth.login(credentials, callback)
|
return callback(null, params.token) if params.token?
|
||||||
|
visuals.widgets.ask('What\'s your token? (visible in the preferences page)', null, callback)
|
||||||
|
|
||||||
], done
|
(token, callback) ->
|
||||||
|
resin.auth.loginWithToken(token, done)
|
||||||
|
|
||||||
|
], done)
|
||||||
|
|
||||||
exports.logout =
|
exports.logout =
|
||||||
signature: 'logout'
|
signature: 'logout'
|
||||||
|
@ -9,7 +9,7 @@ exports.yes =
|
|||||||
exports.optionalApplication =
|
exports.optionalApplication =
|
||||||
signature: 'application'
|
signature: 'application'
|
||||||
parameter: 'application'
|
parameter: 'application'
|
||||||
description: 'application id'
|
description: 'application name'
|
||||||
alias: [ 'a', 'app' ]
|
alias: [ 'a', 'app' ]
|
||||||
|
|
||||||
exports.application = _.defaults
|
exports.application = _.defaults
|
||||||
|
@ -15,7 +15,7 @@ exports.list =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin devices --application 91
|
$ resin devices --application MyApp
|
||||||
'''
|
'''
|
||||||
options: [ commandOptions.application ]
|
options: [ commandOptions.application ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
@ -35,18 +35,18 @@ exports.list =
|
|||||||
return done()
|
return done()
|
||||||
|
|
||||||
exports.info =
|
exports.info =
|
||||||
signature: 'device <id>'
|
signature: 'device <name>'
|
||||||
description: 'list a single device'
|
description: 'list a single device'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to show information about a single device.
|
Use this command to show information about a single device.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin device 317
|
$ resin device MyDevice
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.device.get params.id, (error, device) ->
|
resin.models.device.get params.name, (error, device) ->
|
||||||
return done(error) if error?
|
return done(error) if error?
|
||||||
console.log visuals.widgets.table.vertical device, [
|
console.log visuals.widgets.table.vertical device, [
|
||||||
'id'
|
'id'
|
||||||
@ -67,7 +67,7 @@ exports.info =
|
|||||||
return done()
|
return done()
|
||||||
|
|
||||||
exports.remove =
|
exports.remove =
|
||||||
signature: 'device rm <id>'
|
signature: 'device rm <name>'
|
||||||
description: 'remove a device'
|
description: 'remove a device'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to remove a device from resin.io.
|
Use this command to remove a device from resin.io.
|
||||||
@ -77,14 +77,14 @@ exports.remove =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin device rm 317
|
$ resin device rm MyDevice
|
||||||
$ resin device rm 317 --yes
|
$ resin device rm MyDevice --yes
|
||||||
'''
|
'''
|
||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
visuals.patterns.remove 'device', options.yes, (callback) ->
|
visuals.patterns.remove 'device', options.yes, (callback) ->
|
||||||
resin.models.device.remove(params.id, callback)
|
resin.models.device.remove(params.name, callback)
|
||||||
, done
|
, done
|
||||||
|
|
||||||
exports.identify =
|
exports.identify =
|
||||||
@ -104,7 +104,7 @@ exports.identify =
|
|||||||
resin.models.device.identify(params.uuid, done)
|
resin.models.device.identify(params.uuid, done)
|
||||||
|
|
||||||
exports.rename =
|
exports.rename =
|
||||||
signature: 'device rename <id> [name]'
|
signature: 'device rename <name> [newName]'
|
||||||
description: 'rename a resin device'
|
description: 'rename a resin device'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to rename a device.
|
Use this command to rename a device.
|
||||||
@ -113,20 +113,20 @@ exports.rename =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin device rename 317 MyPi
|
$ resin device rename MyDevice MyPi
|
||||||
$ resin device rename 317
|
$ resin device rename MyDevice
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
async.waterfall [
|
async.waterfall [
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
if not _.isEmpty(params.name)
|
if not _.isEmpty(params.newName)
|
||||||
return callback(null, params.name)
|
return callback(null, params.newName)
|
||||||
visuals.widgets.ask('How do you want to name this device?', null, callback)
|
visuals.widgets.ask('How do you want to name this device?', null, callback)
|
||||||
|
|
||||||
(name, callback) ->
|
(newName, callback) ->
|
||||||
resin.models.device.rename(params.id, name, callback)
|
resin.models.device.rename(params.name, newName, callback)
|
||||||
|
|
||||||
], done
|
], done
|
||||||
|
|
||||||
@ -177,6 +177,7 @@ exports.init =
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
$ resin device init
|
||||||
$ resin device init --application 91
|
$ resin device init --application 91
|
||||||
$ resin device init --application 91 --network ethernet
|
$ resin device init --application 91 --network ethernet
|
||||||
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
||||||
@ -205,7 +206,8 @@ exports.init =
|
|||||||
|
|
||||||
(device, callback) ->
|
(device, callback) ->
|
||||||
params.device = device
|
params.device = device
|
||||||
visuals.patterns.confirm(options.yes, "This will completely erase #{params.device}. Are you sure you want to continue?", callback)
|
message = "This will completely erase #{params.device}. Are you sure you want to continue?"
|
||||||
|
visuals.patterns.confirm(options.yes, message, callback)
|
||||||
|
|
||||||
(confirmed, callback) ->
|
(confirmed, callback) ->
|
||||||
return done() if not confirmed
|
return done() if not confirmed
|
||||||
|
@ -4,8 +4,7 @@ exports.version =
|
|||||||
signature: 'version'
|
signature: 'version'
|
||||||
description: 'output the version number'
|
description: 'output the version number'
|
||||||
help: '''
|
help: '''
|
||||||
Display the Resin CLI, as well as the bundled NodeJS version.
|
Display the Resin CLI version.
|
||||||
'''
|
'''
|
||||||
action: ->
|
action: ->
|
||||||
console.log("#{packageJSON.name}: #{packageJSON.version}")
|
console.log(packageJSON.version)
|
||||||
console.log("node: #{process.version}")
|
|
||||||
|
@ -24,6 +24,8 @@ exports.list =
|
|||||||
console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ]
|
console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ]
|
||||||
return done()
|
return done()
|
||||||
|
|
||||||
|
SSH_KEY_WIDTH = 43
|
||||||
|
|
||||||
exports.info =
|
exports.info =
|
||||||
signature: 'key <id>'
|
signature: 'key <id>'
|
||||||
description: 'list a single ssh key'
|
description: 'list a single ssh key'
|
||||||
@ -39,8 +41,7 @@ exports.info =
|
|||||||
resin.models.key.get params.id, (error, key) ->
|
resin.models.key.get params.id, (error, key) ->
|
||||||
return done(error) if error?
|
return done(error) if error?
|
||||||
|
|
||||||
sshKeyWidth = resin.settings.get('sshKeyWidth')
|
key.public_key = '\n' + visuals.helpers.chop(key.public_key, SSH_KEY_WIDTH)
|
||||||
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth)
|
|
||||||
|
|
||||||
console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ]))
|
console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ]))
|
||||||
return done()
|
return done()
|
||||||
|
@ -9,17 +9,17 @@ exports.set =
|
|||||||
|
|
||||||
If note command isn't passed, the tool attempts to read from `stdin`.
|
If note command isn't passed, the tool attempts to read from `stdin`.
|
||||||
|
|
||||||
To view the notes, use $ resin device <id>.
|
To view the notes, use $ resin device <name>.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin note "My useful note" --device 317
|
$ resin note "My useful note" --device MyDevice
|
||||||
$ cat note.txt | resin note --device 317
|
$ cat note.txt | resin note --device MyDevice
|
||||||
'''
|
'''
|
||||||
options: [
|
options: [
|
||||||
signature: 'device'
|
signature: 'device'
|
||||||
parameter: 'device'
|
parameter: 'device'
|
||||||
description: 'device id'
|
description: 'device name'
|
||||||
alias: [ 'd', 'dev' ]
|
alias: [ 'd', 'dev' ]
|
||||||
required: 'You have to specify a device'
|
required: 'You have to specify a device'
|
||||||
]
|
]
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
_ = require('lodash-contrib')
|
_ = require('lodash-contrib')
|
||||||
fs = require('fs')
|
|
||||||
os = require('os')
|
os = require('os')
|
||||||
async = require('async')
|
async = require('async')
|
||||||
path = require('path')
|
path = require('path')
|
||||||
mkdirp = require('mkdirp')
|
mkdirp = require('mkdirp')
|
||||||
resin = require('resin-sdk')
|
resin = require('resin-sdk')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
progressStream = require('progress-stream')
|
|
||||||
diskio = require('diskio')
|
|
||||||
commandOptions = require('./command-options')
|
commandOptions = require('./command-options')
|
||||||
npm = require('../npm')
|
npm = require('../npm')
|
||||||
packageJSON = require('../../package.json')
|
packageJSON = require('../../package.json')
|
||||||
updateActions = require('./update')
|
updateActions = require('./update')
|
||||||
|
elevate = require('../elevate')
|
||||||
|
|
||||||
exports.download =
|
exports.download =
|
||||||
signature: 'os download <id>'
|
signature: 'os download <id>'
|
||||||
@ -76,9 +74,16 @@ exports.download =
|
|||||||
console.info("Destination file: #{options.output}\n")
|
console.info("Destination file: #{options.output}\n")
|
||||||
|
|
||||||
bar = new visuals.widgets.Progress('Downloading Device OS')
|
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, callback, (state) ->
|
resin.models.os.download osParams, options.output, (error) ->
|
||||||
bar.update(state)
|
spinner.stop()
|
||||||
|
return callback(error) if error?
|
||||||
|
, (state) ->
|
||||||
|
if state?
|
||||||
|
bar.update(state)
|
||||||
|
else
|
||||||
|
spinner.start()
|
||||||
|
|
||||||
], (error) ->
|
], (error) ->
|
||||||
return done(error) if error?
|
return done(error) if error?
|
||||||
@ -119,6 +124,9 @@ exports.install =
|
|||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
|
|
||||||
|
bundle = require('../devices/raspberry-pi')
|
||||||
|
|
||||||
async.waterfall [
|
async.waterfall [
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
@ -136,7 +144,7 @@ exports.install =
|
|||||||
Updating now...
|
Updating now...
|
||||||
'''
|
'''
|
||||||
|
|
||||||
updateActions.update.action(params, options, _.unary(done))
|
updateActions.update.action(params, options, _.unary(callback))
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
return callback(null, params.device) if params.device?
|
return callback(null, params.device) if params.device?
|
||||||
@ -158,41 +166,17 @@ exports.install =
|
|||||||
(confirmed, callback) ->
|
(confirmed, callback) ->
|
||||||
return done() if not confirmed
|
return done() if not confirmed
|
||||||
|
|
||||||
imageFileSize = fs.statSync(params.image).size
|
bar = new visuals.widgets.Progress('Writing Device OS')
|
||||||
|
params.progress = _.bind(bar.update, bar)
|
||||||
if imageFileSize is 0
|
bundle.write(params, callback)
|
||||||
error = new Error("Invalid OS image: #{params.image}. The image is 0 bytes.")
|
|
||||||
return callback(error)
|
|
||||||
|
|
||||||
progress = progressStream
|
|
||||||
length: imageFileSize
|
|
||||||
time: 500
|
|
||||||
|
|
||||||
if not options.quiet
|
|
||||||
bar = new visuals.widgets.Progress('Writing Device OS')
|
|
||||||
|
|
||||||
progress.on 'progress', (status) ->
|
|
||||||
bar.update(status)
|
|
||||||
|
|
||||||
imageFileStream = fs.createReadStream(params.image).pipe(progress)
|
|
||||||
|
|
||||||
diskio.writeStream(params.device, imageFileStream, callback)
|
|
||||||
|
|
||||||
], (error) ->
|
], (error) ->
|
||||||
return done() if not error?
|
return done() if not error?
|
||||||
|
|
||||||
if _.all [
|
if elevate.shouldElevate(error) and not options.fromScript
|
||||||
os.platform() is 'win32'
|
|
||||||
error.code is 'EPERM' or error.code is 'EACCES'
|
|
||||||
|
|
||||||
# Prevent re-running resin-write infinitely
|
|
||||||
# If we have an EPERM or EACCES even after running
|
|
||||||
# windosu, we throw it as there is not much we can do
|
|
||||||
not options.fromScript
|
|
||||||
]
|
|
||||||
windosu = require('windosu')
|
|
||||||
# Need to escape every path to avoid errors
|
# Need to escape every path to avoid errors
|
||||||
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
|
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
|
||||||
windosu.exec("\"#{process.argv[0]}\" #{resinWritePath} \"#{params.image}\" \"#{params.device}\"")
|
elevate.run("\"#{process.argv[0]}\" #{resinWritePath} \"#{params.image}\" \"#{params.device}\"")
|
||||||
else
|
else
|
||||||
return done(error)
|
return done(error)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
open = require('open')
|
open = require('open')
|
||||||
url = require('url')
|
url = require('url')
|
||||||
resin = require('resin-sdk')
|
settings = require('resin-settings-client')
|
||||||
|
|
||||||
exports.preferences =
|
exports.preferences =
|
||||||
signature: 'preferences'
|
signature: 'preferences'
|
||||||
@ -17,6 +17,5 @@ exports.preferences =
|
|||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: ->
|
action: ->
|
||||||
preferencesUrl = resin.settings.get('urls.preferences')
|
absUrl = url.resolve(settings.get('remoteUrl'), '/preferences')
|
||||||
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl)
|
|
||||||
open(absUrl)
|
open(absUrl)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
child_process = require('child_process')
|
||||||
|
president = require('president')
|
||||||
npm = require('../npm')
|
npm = require('../npm')
|
||||||
packageJSON = require('../../package.json')
|
packageJSON = require('../../package.json')
|
||||||
|
|
||||||
@ -20,7 +23,36 @@ exports.update =
|
|||||||
$ resin update
|
$ resin update
|
||||||
'''
|
'''
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
npm.update packageJSON.name, (error, version) ->
|
npm.isUpdated packageJSON.name, packageJSON.version, (error, isUpdated) ->
|
||||||
return done(error) if error?
|
return done(error) if error?
|
||||||
console.info("Upgraded #{packageJSON.name} to v#{version}.")
|
|
||||||
return done(null, version)
|
if isUpdated
|
||||||
|
return done(new Error('You\'re already running the latest version.'))
|
||||||
|
|
||||||
|
onUpdate = (error, stdout, stderr) ->
|
||||||
|
return done(error) if error?
|
||||||
|
return done(new Error(stderr)) if not _.isEmpty(stderr)
|
||||||
|
console.info("Upgraded #{packageJSON.name}.")
|
||||||
|
return done()
|
||||||
|
|
||||||
|
command = "npm install --global #{packageJSON.name}"
|
||||||
|
|
||||||
|
# Attempting to self update using the NPM API was not considered safe.
|
||||||
|
# A safer thing to do is to call npm as a child process
|
||||||
|
# https://github.com/npm/npm/issues/7723
|
||||||
|
child_process.exec command, (error, stdout, stderr) ->
|
||||||
|
return onUpdate(null, stdout, stderr) if error?
|
||||||
|
|
||||||
|
if _.any [
|
||||||
|
|
||||||
|
# 3 is equivalent to EACCES for NPM
|
||||||
|
error.code is 3
|
||||||
|
|
||||||
|
error.code is 'EPERM'
|
||||||
|
error.code is 'ACCES'
|
||||||
|
]
|
||||||
|
return president.execute(command, onUpdate)
|
||||||
|
|
||||||
|
return done(error)
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,10 +125,6 @@ async.waterfall([
|
|||||||
(callback) ->
|
(callback) ->
|
||||||
plugins.register('resin-plugin-', callback)
|
plugins.register('resin-plugin-', callback)
|
||||||
|
|
||||||
(callback) ->
|
|
||||||
dataPrefix = resin.settings.get('dataPrefix')
|
|
||||||
resin.data.prefix.set(dataPrefix, callback)
|
|
||||||
|
|
||||||
(callback) ->
|
(callback) ->
|
||||||
cli = capitano.parse(process.argv)
|
cli = capitano.parse(process.argv)
|
||||||
|
|
||||||
|
22
lib/devices/raspberry-pi.coffee
Normal file
22
lib/devices/raspberry-pi.coffee
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
fs = require('fs')
|
||||||
|
progressStream = require('progress-stream')
|
||||||
|
diskio = require('diskio')
|
||||||
|
|
||||||
|
exports.name = 'Raspberry Pi'
|
||||||
|
|
||||||
|
exports.write = (options, callback) ->
|
||||||
|
imageFileSize = fs.statSync(options.image).size
|
||||||
|
|
||||||
|
if imageFileSize is 0
|
||||||
|
error = new Error("Invalid OS image: #{options.image}. The image is 0 bytes.")
|
||||||
|
return callback(error)
|
||||||
|
|
||||||
|
progress = progressStream
|
||||||
|
length: imageFileSize
|
||||||
|
time: 500
|
||||||
|
|
||||||
|
if not options.quiet
|
||||||
|
progress.on('progress', options.progress)
|
||||||
|
|
||||||
|
imageFileStream = fs.createReadStream(options.image).pipe(progress)
|
||||||
|
diskio.writeStream(options.device, imageFileStream, callback)
|
16
lib/elevate.coffee
Normal file
16
lib/elevate.coffee
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
os = require('os')
|
||||||
|
path = require('path')
|
||||||
|
|
||||||
|
isWindows = ->
|
||||||
|
return os.platform() is 'win32'
|
||||||
|
|
||||||
|
exports.shouldElevate = (error) ->
|
||||||
|
return _.all [
|
||||||
|
isWindows()
|
||||||
|
error.code is 'EPERM' or error.code is 'EACCES'
|
||||||
|
]
|
||||||
|
|
||||||
|
exports.run = (command) ->
|
||||||
|
return if not isWindows()
|
||||||
|
require('windosu').exec(command)
|
@ -2,34 +2,6 @@ npm = require('npm')
|
|||||||
async = require('async')
|
async = require('async')
|
||||||
_ = require('lodash-contrib')
|
_ = require('lodash-contrib')
|
||||||
|
|
||||||
exports.update = (name, callback) ->
|
|
||||||
async.waterfall([
|
|
||||||
|
|
||||||
(callback) ->
|
|
||||||
options =
|
|
||||||
|
|
||||||
# TODO: There is no way to quiet npm install completely.
|
|
||||||
# Some output is still shown once the module is updated
|
|
||||||
# https://github.com/npm/npm/issues/2040
|
|
||||||
loglevel: 'silent'
|
|
||||||
global: true
|
|
||||||
|
|
||||||
npm.load(options, _.unary(callback))
|
|
||||||
|
|
||||||
(callback) ->
|
|
||||||
npm.commands.update [ name ], (error, data) ->
|
|
||||||
return callback(error, data)
|
|
||||||
|
|
||||||
(data, callback) ->
|
|
||||||
if _.isEmpty(data)
|
|
||||||
error = new Error('You are already running the latest version')
|
|
||||||
return callback(error)
|
|
||||||
|
|
||||||
newVersion = _.last(_.first(_.last(data)).split('@'))
|
|
||||||
return callback(null, newVersion)
|
|
||||||
|
|
||||||
], callback)
|
|
||||||
|
|
||||||
exports.getLatestVersion = (name, callback) ->
|
exports.getLatestVersion = (name, callback) ->
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
|
||||||
|
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "resin-cli",
|
"name": "resin-cli",
|
||||||
"version": "0.4.0",
|
"version": "0.8.1",
|
||||||
"description": "Git Push to your devices",
|
"description": "Git Push to your devices",
|
||||||
"main": "./lib/actions/index.coffee",
|
"main": "./lib/actions/index.coffee",
|
||||||
"homepage": "https://github.com/resin-io/resin-cli",
|
"homepage": "https://github.com/resin-io/resin-cli",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "gulp build",
|
"prepublish": "gulp build",
|
||||||
"test": "gulp test",
|
"test": "gulp test",
|
||||||
"doc": "./scripts/extract-documentation.sh doc lib/actions"
|
"doc": "mkdir -p doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"resin",
|
"resin",
|
||||||
@ -33,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "~1.9.2",
|
"chai": "~1.9.2",
|
||||||
|
"ent": "^2.2.0",
|
||||||
"gulp": "~3.8.9",
|
"gulp": "~3.8.9",
|
||||||
"gulp-coffee": "^2.2.0",
|
"gulp-coffee": "^2.2.0",
|
||||||
"gulp-coffeelint": "~0.4.0",
|
"gulp-coffeelint": "~0.4.0",
|
||||||
@ -56,13 +57,15 @@
|
|||||||
"lodash": "~2.4.1",
|
"lodash": "~2.4.1",
|
||||||
"lodash-contrib": "~241.4.14",
|
"lodash-contrib": "~241.4.14",
|
||||||
"mkdirp": "~0.5.0",
|
"mkdirp": "~0.5.0",
|
||||||
"nplugm": "^2.1.0",
|
"nplugm": "^2.2.0",
|
||||||
"npm": "^2.6.1",
|
"npm": "^2.6.1",
|
||||||
"open": "0.0.5",
|
"open": "0.0.5",
|
||||||
|
"president": "^1.0.0",
|
||||||
"progress-stream": "^0.5.0",
|
"progress-stream": "^0.5.0",
|
||||||
"resin-cli-visuals": "^0.0.8",
|
"resin-cli-visuals": "^0.1.0",
|
||||||
"resin-sdk": "^0.0.2",
|
"resin-sdk": "^1.2.0",
|
||||||
"resin-vcs": "^1.0.0",
|
"resin-settings-client": "^1.0.0",
|
||||||
|
"resin-vcs": "^1.1.0",
|
||||||
"underscore.string": "~2.4.0",
|
"underscore.string": "~2.4.0",
|
||||||
"update-notifier": "^0.3.1"
|
"update-notifier": "^0.3.1"
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
OUTPUT=$1
|
|
||||||
INPUT=$2
|
|
||||||
|
|
||||||
for file in $INPUT/*.coffee; do
|
|
||||||
|
|
||||||
# Omit this unecessary files
|
|
||||||
if [ `basename "$file"` == 'index.coffee' ] || [ `basename "$file"` == 'command-options.coffee' ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
filename=`basename "${file%.*}"`
|
|
||||||
output=$OUTPUT/$filename
|
|
||||||
mkdir -p $output
|
|
||||||
./node_modules/coffee-script/bin/coffee extras/capitano-doc/index.coffee markdown "$file" "$output"
|
|
||||||
echo "[CapitanoDoc] Processed $file to $output"
|
|
||||||
done
|
|
Reference in New Issue
Block a user