From 955e49fff26e580c16ce1f15051ab69f49814166 Mon Sep 17 00:00:00 2001 From: mmcw-dev Date: Mon, 25 Feb 2019 20:24:30 -0500 Subject: [PATCH] Add exit module to cli tool --- cli/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/index.js b/cli/index.js index 104ab51..6df7180 100644 --- a/cli/index.js +++ b/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)