2015-02-25 15:12:58 +00:00
|
|
|
_ = require('lodash')
|
|
|
|
async = require('async')
|
2015-01-30 12:45:38 +00:00
|
|
|
visuals = require('resin-cli-visuals')
|
2015-01-30 15:38:46 +00:00
|
|
|
drivelist = require('drivelist')
|
2015-01-30 12:45:38 +00:00
|
|
|
|
|
|
|
exports.list =
|
|
|
|
signature: 'drives'
|
|
|
|
description: 'list available drives'
|
|
|
|
help: '''
|
|
|
|
Use this command to list all drives that are connected to your machine.
|
|
|
|
|
|
|
|
Examples:
|
2015-03-03 14:14:16 +00:00
|
|
|
|
2015-01-30 12:45:38 +00:00
|
|
|
$ resin drives
|
|
|
|
'''
|
|
|
|
permission: 'user'
|
|
|
|
action: (params, options, done) ->
|
2015-01-30 15:38:46 +00:00
|
|
|
drivelist.list (error, drives) ->
|
2015-01-30 12:45:38 +00:00
|
|
|
return done(error) if error?
|
|
|
|
|
2015-02-25 15:12:58 +00:00
|
|
|
async.reject drives, drivelist.isSystem, (removableDrives) ->
|
2015-01-30 12:45:38 +00:00
|
|
|
|
2015-02-25 15:12:58 +00:00
|
|
|
if _.isEmpty(removableDrives)
|
|
|
|
return done(new Error('No removable devices available'))
|
|
|
|
|
|
|
|
console.log visuals.widgets.table.horizontal removableDrives, [
|
|
|
|
'device'
|
|
|
|
'description'
|
|
|
|
'size'
|
|
|
|
]
|
|
|
|
|
|
|
|
return done()
|