2016-01-04 03:58:51 +00:00
|
|
|
###
|
2017-06-14 21:20:15 +00:00
|
|
|
Copyright 2016-2017 Resin.io
|
2016-01-04 03:58:51 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
###
|
|
|
|
|
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-07-22 22:06:53 +00:00
|
|
|
To view the notes, use $ resin device <uuid>.
|
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
|
|
|
|
2016-01-21 14:23:40 +00:00
|
|
|
$ resin note "My useful note" --device 7cf02a6
|
|
|
|
$ cat note.txt | resin note --device 7cf02a6
|
2015-01-15 17:10:14 +00:00
|
|
|
'''
|
|
|
|
options: [
|
|
|
|
signature: 'device'
|
|
|
|
parameter: 'device'
|
2015-07-22 22:06:53 +00:00
|
|
|
description: 'device uuid'
|
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-12-07 14:32:24 +00:00
|
|
|
Promise = require('bluebird')
|
|
|
|
_ = require('lodash')
|
2017-01-25 18:32:07 +00:00
|
|
|
resin = require('resin-sdk-preconfigured')
|
2015-12-07 14:32:24 +00:00
|
|
|
|
2015-08-13 18:12:22 +00:00
|
|
|
Promise.try ->
|
|
|
|
if _.isEmpty(params.note)
|
|
|
|
throw new Error('Missing note content')
|
2015-04-29 18:39:46 +00:00
|
|
|
|
2015-08-13 18:12:22 +00:00
|
|
|
resin.models.device.note(options.device, params.note)
|
|
|
|
.nodeify(done)
|