mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 09:51:58 +00:00
Implement note command
This commit is contained in:
parent
16ddd8ccb6
commit
3f9270cbb9
@ -5,6 +5,7 @@ module.exports =
|
||||
env: require('./environment-variables')
|
||||
keys: require('./keys')
|
||||
logs: require('./logs')
|
||||
notes: require('./notes')
|
||||
preferences: require('./preferences')
|
||||
os: require('./os')
|
||||
help: require('./help')
|
||||
|
21
lib/actions/notes.coffee
Normal file
21
lib/actions/notes.coffee
Normal file
@ -0,0 +1,21 @@
|
||||
async = require('async')
|
||||
permissions = require('../permissions/permissions')
|
||||
errors = require('../errors/errors')
|
||||
helpers = require('../helpers/helpers')
|
||||
resin = require('../resin')
|
||||
|
||||
exports.set = permissions.user (params, options) ->
|
||||
if not options.device?
|
||||
errors.handle(new Error('You have to specify a device'))
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
if not params.note?
|
||||
helpers.readStdin(callback)
|
||||
return callback(null, params.note)
|
||||
|
||||
(note, callback) ->
|
||||
resin.models.device.note(options.device, note, callback)
|
||||
|
||||
], errors.handle)
|
@ -59,6 +59,12 @@ applicationOption =
|
||||
description: 'application id'
|
||||
alias: [ 'a', 'app' ]
|
||||
|
||||
deviceOption =
|
||||
signature: 'device'
|
||||
parameter: 'device'
|
||||
description: 'device id'
|
||||
alias: [ 'd', 'dev' ]
|
||||
|
||||
# ---------- Auth Module ----------
|
||||
capitano.command
|
||||
signature: 'login [credentials]'
|
||||
@ -279,6 +285,24 @@ capitano.command
|
||||
'''
|
||||
action: actions.device.identify
|
||||
|
||||
# ---------- Device Module ----------
|
||||
capitano.command
|
||||
signature: 'note [note]'
|
||||
description: 'set a device note'
|
||||
help: '''
|
||||
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
|
||||
'''
|
||||
action: actions.notes.set
|
||||
options: [ deviceOption ]
|
||||
|
||||
# ---------- Preferences Module ----------
|
||||
capitano.command
|
||||
signature: 'preferences'
|
||||
|
@ -142,6 +142,30 @@ exports.rename = (id, name, callback) ->
|
||||
.catch (error) ->
|
||||
return callback(error)
|
||||
|
||||
# Note a device
|
||||
#
|
||||
# @param {String, Number} id device id
|
||||
# @param {String} note the note
|
||||
# @param {Function} callback callback(error)
|
||||
#
|
||||
# @example Note device
|
||||
# resin.models.device.note 317, 'My useful note', (error) ->
|
||||
# throw error if error?
|
||||
# console.log("Device has been noted!")
|
||||
#
|
||||
exports.note = (id, note, callback) ->
|
||||
return pine.patch
|
||||
resource: 'device'
|
||||
id: id
|
||||
data:
|
||||
note: note
|
||||
|
||||
.then ->
|
||||
return callback()
|
||||
|
||||
.catch (error) ->
|
||||
return callback(error)
|
||||
|
||||
# Get display name for a device
|
||||
#
|
||||
# For a list of supported devices, see getSupportedDeviceTypes()
|
||||
|
@ -74,6 +74,6 @@
|
||||
"conf.js": "~0.1.1",
|
||||
"coffee-script": "~1.8.0",
|
||||
"git-cli": "~0.8.2",
|
||||
"capitano": "~1.0.3"
|
||||
"capitano": "~1.0.4"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user