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