2015-04-29 18:39:46 +00:00
|
|
|
_ = require('lodash')
|
2014-12-24 16:40:40 +00:00
|
|
|
async = require('async')
|
2015-01-08 12:04:37 +00:00
|
|
|
resin = require('resin-sdk')
|
2014-12-24 16:40:40 +00:00
|
|
|
|
2015-01-15 17:10:14 +00:00
|
|
|
exports.set =
|
2015-02-10 15:32:06 +00:00
|
|
|
signature: 'note <|note>'
|
2015-01-15 17:10:14 +00:00
|
|
|
description: 'set a device note'
|
|
|
|
help: '''
|
|
|
|
Use this command to set or update a device note.
|
2014-12-24 16:40:40 +00:00
|
|
|
|
2015-01-15 17:10:14 +00:00
|
|
|
If note command isn't passed, the tool attempts to read from `stdin`.
|
2014-12-24 16:40:40 +00:00
|
|
|
|
2015-03-23 12:17:55 +00:00
|
|
|
To view the notes, use $ resin device <name>.
|
2014-12-24 16:40:40 +00:00
|
|
|
|
2015-01-15 17:10:14 +00:00
|
|
|
Examples:
|
2015-03-03 14:14:16 +00:00
|
|
|
|
2015-03-23 12:17:55 +00:00
|
|
|
$ resin note "My useful note" --device MyDevice
|
|
|
|
$ cat note.txt | resin note --device MyDevice
|
2015-01-15 17:10:14 +00:00
|
|
|
'''
|
|
|
|
options: [
|
|
|
|
signature: 'device'
|
|
|
|
parameter: 'device'
|
2015-03-23 12:17:55 +00:00
|
|
|
description: 'device name'
|
2015-01-15 17:10:14 +00:00
|
|
|
alias: [ 'd', 'dev' ]
|
|
|
|
required: 'You have to specify a device'
|
|
|
|
]
|
2015-01-16 12:34:59 +00:00
|
|
|
permission: 'user'
|
|
|
|
action: (params, options, done) ->
|
2015-04-29 18:39:46 +00:00
|
|
|
|
|
|
|
if _.isEmpty(params.note)
|
|
|
|
return done(new Error('Missing note content'))
|
|
|
|
|
2015-02-10 15:32:06 +00:00
|
|
|
resin.models.device.note(options.device, params.note, done)
|