balena-cli/lib/actions/drive.coffee

33 lines
742 B
CoffeeScript
Raw Normal View History

_ = 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-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?
async.reject drives, drivelist.isSystem, (removableDrives) ->
2015-01-30 12:45:38 +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()