const Directive = require('flitter-cli/Directive') const path = require('path') class RunDirective extends Directive { static options() { return [ '--hosts -h {host file} | path to the host definition file', '{routine file} | path to the routine definition file', ] } static name() { return 'run' } static help() { return 'Run a specified routine' } async handle(app, argv) { const routine_path = this.option('routine file') const host_path = this.option('hosts') if ( !host_path ) return this.error('Missing required parameter: --hosts') let routine_conf let host_conf try { routine_conf = require(path.resolve(routine_path)) } catch (e) { this.error('Routine file is invalid.') return this.output.debug(e) } try { host_conf = require(path.resolve(host_path)) } catch (e) { this.error('Host definition file is invalid.') return this.output.debug(e) } console.log({ routine_conf, host_conf }) } } module.exports = exports = RunDirective