Merge pull request #135 from resin-io/remove/examples-commands

Remove examples commands
This commit is contained in:
Juan Cruz Viotti 2015-08-05 07:04:03 -04:00
commit ffb48c8669
10 changed files with 22 additions and 389 deletions

View File

@ -1,86 +0,0 @@
(function() {
var _, async, examplesData, fs, mkdirp, path, vcs, visuals;
mkdirp = require('mkdirp');
async = require('async');
fs = require('fs');
path = require('path');
_ = require('lodash');
visuals = require('resin-cli-visuals');
vcs = require('resin-vcs');
examplesData = require('../data/examples.json');
exports.list = {
signature: 'examples',
description: 'list all example applications',
help: 'Use this command to list available example applications from resin.io\n\nExample:\n\n $ resin examples',
permission: 'user',
action: function() {
examplesData = _.map(examplesData, function(example, index) {
example.id = index + 1;
return example;
});
examplesData = _.map(examplesData, function(example) {
if (example.author == null) {
example.author = 'Unknown';
}
return example;
});
return console.log(visuals.table.horizontal(examplesData, ['name', 'display_name', 'author']));
}
};
exports.info = {
signature: 'example <name>',
description: 'list a single example application',
help: 'Use this command to show information of a single example application\n\nExample:\n\n $ resin example cimon',
permission: 'user',
action: function(params, options, done) {
var example;
example = _.findWhere(examplesData, {
name: params.name
});
if (example == null) {
return done(new Error("Unknown example: " + params.name));
}
if (example.author == null) {
example.author = 'Unknown';
}
console.log(visuals.table.vertical(example, ["$" + example.display_name + "$", 'description', 'author', 'repository']));
return done();
}
};
exports.clone = {
signature: 'example clone <name>',
description: 'clone an example application',
help: 'Use this command to clone an example application to the current directory\n\nThis command outputs information about the cloning process.\nUse `--quiet` to remove that output.\n\nExample:\n\n $ resin example clone cimon',
permission: 'user',
action: function(params, options, done) {
var currentDirectory, destination, example;
example = _.findWhere(examplesData, {
name: params.name
});
if (example == null) {
return done(new Error("Unknown example: " + params.name));
}
currentDirectory = process.cwd();
destination = path.join(currentDirectory, example.name);
return mkdirp(destination, function(error) {
if (error != null) {
return done(error);
}
console.info("Cloning " + example.display_name + " to " + destination);
return vcs.clone(example.repository, destination).nodeify(done);
});
}
};
}).call(this);

View File

@ -12,7 +12,6 @@
notes: require('./notes'),
preferences: require('./preferences'),
help: require('./help'),
examples: require('./examples'),
plugin: require('./plugin')
};

View File

@ -129,12 +129,6 @@
capitano.command(actions.logs);
capitano.command(actions.examples.list);
capitano.command(actions.examples.clone);
capitano.command(actions.examples.info);
capitano.command(actions.plugin.list);
capitano.command(actions.plugin.install);

View File

@ -32,12 +32,6 @@
"lib/actions/environment-variables.coffee"
]
},
{
"title": "Examples",
"files": [
"lib/actions/examples.coffee"
]
},
{
"title": "Help",
"files": [
@ -79,12 +73,6 @@
"files": [
"lib/actions/preferences.coffee"
]
},
{
"title": "Update",
"files": [
"lib/actions/update.coffee"
]
}
]
}

View File

@ -34,12 +34,12 @@ Now you have access to all the commands referenced below.
- Device
- [devices](#devices)
- [device &#60;name&#62;](#device-60-name-62-)
- [device rm &#60;name&#62;](#device-rm-60-name-62-)
- [device &#60;uuid&#62;](#device-60-uuid-62-)
- [device rm &#60;uuid&#62;](#device-rm-60-uuid-62-)
- [device identify &#60;uuid&#62;](#device-identify-60-uuid-62-)
- [device rename &#60;name&#62; [newName]](#device-rename-60-name-62-newname-)
- [device rename &#60;uuid&#62; [newName]](#device-rename-60-uuid-62-newname-)
- [devices supported](#devices-supported)
- [device await &#60;name&#62;](#device-await-60-name-62-)
- [device await &#60;uuid&#62;](#device-await-60-uuid-62-)
- [device init [device]](#device-init-device-)
- Drive
@ -53,12 +53,6 @@ Now you have access to all the commands referenced below.
- [env add &#60;key&#62; [value]](#env-add-60-key-62-value-)
- [env rename &#60;id&#62; &#60;value&#62;](#env-rename-60-id-62-60-value-62-)
- Examples
- [examples](#examples)
- [example &#60;name&#62;](#example-60-name-62-)
- [example clone &#60;name&#62;](#example-clone-60-name-62-)
- Help
- [help [command...]](#help-command-)
@ -94,10 +88,6 @@ Now you have access to all the commands referenced below.
- [preferences](#preferences)
- Update
- [update](#update)
# Application
## app create &#60;name&#62;
@ -285,15 +275,15 @@ Examples:
application name
## device &#60;name&#62;
## device &#60;uuid&#62;
Use this command to show information about a single device.
Examples:
$ resin device MyDevice
$ resin device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
## device rm &#60;name&#62;
## device rm &#60;uuid&#62;
Use this command to remove a device from resin.io.
@ -302,8 +292,8 @@ You can avoid this by passing the `--yes` boolean option.
Examples:
$ resin device rm MyDevice
$ resin device rm MyDevice --yes
$ resin device rm 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
$ resin device rm 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 --yes
### Options
@ -321,7 +311,7 @@ Examples:
$ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
## device rename &#60;name&#62; [newName]
## device rename &#60;uuid&#62; [newName]
Use this command to rename a device.
@ -329,8 +319,8 @@ If you omit the name, you'll get asked for it interactively.
Examples:
$ resin device rename MyDevice MyPi
$ resin device rename MyDevice
$ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 MyPi
$ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
## devices supported
@ -340,7 +330,7 @@ Examples:
$ resin devices supported
## device await &#60;name&#62;
## device await &#60;uuid&#62;
Use this command to await for a device to become online.
@ -352,8 +342,8 @@ You can configure the poll interval with the --interval option (defaults to 3000
Examples:
$ resin device await MyDevice
$ resin device await MyDevice --interval 1000
$ resin device await 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
$ resin device await 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 --interval 1000
### Options
@ -435,7 +425,7 @@ Example:
$ resin envs --application MyApp
$ resin envs --application MyApp --verbose
$ resin envs --device MyDevice
$ resin envs --device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
### Options
@ -524,35 +514,6 @@ Examples:
device name
# Examples
## examples
Use this command to list available example applications from resin.io
Example:
$ resin examples
## example &#60;name&#62;
Use this command to show information of a single example application
Example:
$ resin example cimon
## example clone &#60;name&#62;
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 cimon
# Help
## help [command...]
@ -632,9 +593,6 @@ 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.
@ -644,15 +602,10 @@ 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 &#60;num&#62;
number of lines to display
#### --tail, -t
continuously stream output
@ -665,18 +618,18 @@ 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>.
To view the notes, use $ resin device <uuid>.
Examples:
$ resin note "My useful note" --device MyDevice
$ cat note.txt | resin note --device MyDevice
$ resin note "My useful note" --device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
$ cat note.txt | resin note --device 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
### Options
#### --device, --d,dev, --d,dev &#60;device&#62;
device name
device uuid
# Plugin
@ -739,21 +692,3 @@ 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

View File

@ -14,7 +14,6 @@ OPTIONS =
coffee: [ 'lib/**/*.coffee', 'gulpfile.coffee' ]
app: [ 'lib/**/*.coffee', '!lib/**/*.spec.coffee' ]
tests: 'tests/**/*.spec.coffee'
json: [ 'lib/**/*.json' ]
directories:
build: 'build/'
@ -24,15 +23,11 @@ gulp.task 'test', ->
reporter: 'min'
}))
gulp.task 'coffee', [ 'test', 'lint', 'json' ], ->
gulp.task 'coffee', [ 'test', 'lint' ], ->
gulp.src(OPTIONS.files.app)
.pipe(coffee())
.pipe(gulp.dest(OPTIONS.directories.build))
gulp.task 'json', ->
gulp.src(OPTIONS.files.json)
.pipe(gulp.dest(OPTIONS.directories.build))
gulp.task 'lint', ->
gulp.src(OPTIONS.files.coffee)
.pipe(coffeelint({
@ -45,4 +40,4 @@ gulp.task 'build', [
]
gulp.task 'watch', [ 'test', 'lint', 'coffee' ], ->
gulp.watch([ OPTIONS.files.coffee, OPTIONS.files.json ], [ 'coffee' ])
gulp.watch([ OPTIONS.files.coffee ], [ 'coffee' ])

View File

@ -1,90 +0,0 @@
mkdirp = require('mkdirp')
async = require('async')
fs = require('fs')
path = require('path')
_ = require('lodash')
visuals = require('resin-cli-visuals')
vcs = require('resin-vcs')
examplesData = require('../data/examples.json')
exports.list =
signature: 'examples'
description: 'list all example applications'
help: '''
Use this command to list available example applications from resin.io
Example:
$ resin examples
'''
permission: 'user'
action: ->
examplesData = _.map examplesData, (example, index) ->
example.id = index + 1
return example
examplesData = _.map examplesData, (example) ->
example.author ?= 'Unknown'
return example
console.log visuals.table.horizontal examplesData, [
'name'
'display_name'
'author'
]
exports.info =
signature: 'example <name>'
description: 'list a single example application'
help: '''
Use this command to show information of a single example application
Example:
$ resin example cimon
'''
permission: 'user'
action: (params, options, done) ->
example = _.findWhere(examplesData, name: params.name)
if not example?
return done(new Error("Unknown example: #{params.name}"))
example.author ?= 'Unknown'
console.log visuals.table.vertical example, [
"$#{example.display_name}$"
'description'
'author'
'repository'
]
return done()
exports.clone =
signature: 'example clone <name>'
description: 'clone an example application'
help: '''
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 cimon
'''
permission: 'user'
action: (params, options, done) ->
example = _.findWhere(examplesData, name: params.name)
if not example?
return done(new Error("Unknown example: #{params.name}"))
currentDirectory = process.cwd()
destination = path.join(currentDirectory, example.name)
mkdirp destination, (error) ->
return done(error) if error?
console.info("Cloning #{example.display_name} to #{destination}")
vcs.clone(example.repository, destination).nodeify(done)

View File

@ -11,5 +11,4 @@ module.exports =
notes: require('./notes')
preferences: require('./preferences')
help: require('./help')
examples: require('./examples')
plugin: require('./plugin')

View File

@ -103,11 +103,6 @@ capitano.command(actions.env.remove)
# ---------- Logs Module ----------
capitano.command(actions.logs)
# ---------- Examples Module ----------
capitano.command(actions.examples.list)
capitano.command(actions.examples.clone)
capitano.command(actions.examples.info)
# ---------- Plugins Module ----------
capitano.command(actions.plugin.list)
capitano.command(actions.plugin.install)

View File

@ -1,96 +0,0 @@
[
{
"name": "basic-resin-node-project",
"display_name": "Node.js Starter Project",
"repository": "https://github.com/resin-io/basic-resin-node-project",
"description": "This is a simple Hello, World project for node.js designed to act as a basis for future work. It demonstrates how to install native Linux packages and configure your application."
},
{
"name": "cimon",
"display_name": "Cimon",
"repository": "https://bitbucket.org/efwe/cimon",
"description": "A simple tool for reading temperatures from a USB-enabled thermometer. This project is used as the backend to efwe's awesome temperature visualisation at 123k.de.",
"author": "efwe"
},
{
"name": "firebaseDTL",
"display_name": "Digital Temperature Logger",
"repository": "https://github.com/shaunmulligan/firebaseDTL",
"description": "A Firebase-backed Digital Temperature Logger allowing you to connect devices with multiple temperature sensors to a central cloud-based datastore.",
"author": "Shaun Mulligan"
},
{
"name": "digitiser",
"display_name": "Digitiser",
"repository": "https://github.com/shaunmulligan/digitiser",
"description": "A tool for displaying integer values from a JSON endpoint on a MAX7219 7-segment display.",
"author": "Shaun Mulligan"
},
{
"name": "basic-gpio",
"display_name": "Example Pi Pins Application",
"repository": "https://github.com/shaunmulligan/basic-gpio",
"description": "A simple application which demonstrates the use of the Pi Pins library to interface with GPIO.",
"author": "Shaun Mulligan"
},
{
"name": "coder",
"display_name": "Google Coder",
"repository": "https://github.com/resin-io/coder",
"description": "Resin.io-enabled version of Google's excellent Coder project which makes it easy to develop web projects on your device."
},
{
"name": "hoversnap",
"display_name": "Hoversnap",
"repository": "https://github.com/resin-io/hoversnap",
"description": "A tool for controlling a camera using a foot switch in order to capture shots in which people appear to be flying."
},
{
"name": "resin-piminer",
"display_name": "Pi Miner",
"repository": "https://github.com/csquared/resin-piminer",
"description": "A bitcoin miner for the Raspberry Pi.",
"author": "Chris Continanza"
},
{
"name": "resin-cctv",
"display_name": "Resin CCTV",
"repository": "https://github.com/abresas/resin-cctv",
"description": "A project which allows you to use your devices as a CCTV camera system which hooks into Dropbox.",
"author": "Aleksis Brezas"
},
{
"name": "resin_player",
"display_name": "Resin Player",
"repository": "https://bitbucket.org/lifeeth/resin_player/",
"description": "A project which allows you to play squeezebox media through your devices.",
"author": "Praneeth Bodduluri"
},
{
"name": "salesforceTemp",
"display_name": "Salesforce Temperature Probe",
"repository": "https://github.com/shaunmulligan/salesforceTemp",
"description": "Example application for interfacing with a temperature probe using Salesforce.com.",
"author": "Shaun Mulligan"
},
{
"name": "sms2speech",
"display_name": "SMS to Speech",
"repository": "https://github.com/alexandrosm/sms2speech",
"description": "A simple tool which uses Twillio to read out incoming SMS messages.",
"author": "Alexandros Marinos"
},
{
"name": "resin-kiosk",
"display_name": "Simple Digitiser Kiosk",
"repository": "https://bitbucket.org/lifeeth/resin-kiosk",
"description": "Displays values from a JSON endpoint on your browser in kiosk mode",
"author": "Praneeth Bodduluri"
},
{
"name": "text2speech",
"display_name": "Text to Speech Converter",
"repository": "https://github.com/resin-io/text2speech",
"description": "A simple application that makes your device speak out loud."
}
]