Make use of new Capitano stdin support to get rid of helpers/

This commit is contained in:
Juan Cruz Viotti 2015-02-10 11:32:06 -04:00
parent 8275275a05
commit 65fbe12f22
4 changed files with 6 additions and 21 deletions

View File

@ -3,7 +3,7 @@ _.str = require('underscore.string')
async = require('async')
fs = require('fs')
resin = require('resin-sdk')
helpers = require('../helpers/helpers')
capitano = require('capitano')
visuals = require('resin-cli-visuals')
commandOptions = require('./command-options')
@ -84,7 +84,8 @@ exports.add =
if params.path?
fs.readFile(params.path, encoding: 'utf8', callback)
else
helpers.readStdin(callback)
capitano.utils.getStdin (data) ->
return callback(null, data)
(key, callback) ->
resin.models.key.create(params.name, key, callback)

View File

@ -1,9 +1,8 @@
async = require('async')
helpers = require('../helpers/helpers')
resin = require('resin-sdk')
exports.set =
signature: 'note [note]'
signature: 'note <|note>'
description: 'set a device note'
help: '''
Use this command to set or update a device note.
@ -25,14 +24,4 @@ exports.set =
]
permission: 'user'
action: (params, options, done) ->
async.waterfall([
(callback) ->
if not params.note?
return helpers.readStdin(callback)
return callback(null, params.note)
(note, callback) ->
resin.models.device.note(options.device, note, callback)
], done)
resin.models.device.note(options.device, params.note, done)

View File

@ -1,5 +0,0 @@
getStdin = require('get-stdin')
exports.readStdin = (callback) ->
getStdin (result) ->
return callback(null, result)

View File

@ -46,7 +46,7 @@
},
"dependencies": {
"async": "~0.9.0",
"capitano": "~1.3.1",
"capitano": "~1.5.0",
"coffee-script": "~1.8.0",
"conf.js": "^0.1.1",
"diskio": "^1.0.0",