Add exit module to cli tool

This commit is contained in:
mmcw-dev 2019-02-25 20:24:30 -05:00
parent 7398f7993d
commit 955e49fff2
1 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,7 @@ const cfg = require('../app/data/cfg.json')
const pkg = require('./package.json') const pkg = require('./package.json')
const delay = require('delay') const delay = require('delay')
const exit = require('exit')
const intval = require('intval') const intval = require('intval')
const arduino = require('arduino')(cfg, ee) const arduino = require('arduino')(cfg, ee)
const Mscript = require('mscript') const Mscript = require('mscript')
@ -19,6 +20,7 @@ const dev = require('device')
let log let log
let readline let readline
let devices
async function command () { async function command () {
return new Promise ((resolve, reject) => { return new Promise ((resolve, reject) => {
@ -58,12 +60,18 @@ async function main (arg) {
log.info('mcopy-cli') log.info('mcopy-cli')
try { try {
await arduino.enumerate() devices = await arduino.enumerate()
} catch (err) { } catch (err) {
log.error('Error enumerating devices') log.error('Error enumerating devices')
log.error(err) log.error(err)
} }
if (!devices ||devices.length > 1) {
return exit('No devices found', 1)
}
await dev.all(devices)
if (arg.pattern) { if (arg.pattern) {
} }
@ -82,6 +90,7 @@ program
.option('-l, --live', 'Live control mode') .option('-l, --live', 'Live control mode')
.option('-f, --frames', 'Number of frames to capture with camera') .option('-f, --frames', 'Number of frames to capture with camera')
.option('-p, --pattern', 'Pattern of sequence to be repeated') .option('-p, --pattern', 'Pattern of sequence to be repeated')
.option('-i, --intval', 'URL of intval3')
.option('-m, --mscript', 'Execute an mscript file') .option('-m, --mscript', 'Execute an mscript file')
.option('-q, --quiet', 'Suppresses all log messages') .option('-q, --quiet', 'Suppresses all log messages')
.parse(process.argv) .parse(process.argv)