38 lines
No EOL
1.1 KiB
JavaScript
Executable file
38 lines
No EOL
1.1 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
const program = require('commander');
|
|
const Exec = require('../lib/index');
|
|
|
|
function myParseInt(value, dummyPrevious) {
|
|
// parseInt takes a string and an optional radix
|
|
if (!value) return 1000;
|
|
return parseInt(value);
|
|
}
|
|
function args(value, previous) {
|
|
if (!previous) previous === [];
|
|
return [...previous, value];
|
|
}
|
|
program.version('iexec v0.0.1, Made with ♥️ by Sagi Dayan');
|
|
|
|
program.option('-c, --command <command>', 'Command to execute wrapped in', null)
|
|
.option('-a, --arg [arg]', 'Arguments for the command', args, [])
|
|
.option(
|
|
'-i, --interval [milliseconds]', 'Interval milliseconds', myParseInt,
|
|
1000)
|
|
.option(
|
|
'-w, --wait', 'Wait until execution ends before running a new process',
|
|
false);
|
|
|
|
program.parse(process.argv);
|
|
console.log(program.args);
|
|
if (!program.command) {
|
|
console.error('Must provide a command to run. Use -c to pass a command');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(program.wait);
|
|
|
|
const _needToWait = program.wait;
|
|
const _command = program.command;
|
|
const _args = program.arg;
|
|
const _interval = program.interval;
|
|
Exec.start(_command, _args, _needToWait, _interval); |