Files
switchmon/cli.js
Thomas Ruoff 9160bd1c82 major refactoring - well almost a rewrite
* changed the output of --list command to be more sane
* use promises and simplify API of swm.js
* simplify swm.js a bit
2019-11-15 00:25:31 +01:00

35 lines
714 B
JavaScript
Executable File

#!/usr/bin/env node
'use strict';
const argv = require('minimist')(process.argv.slice(2));
const swm = require('./swm.js');
const config = require('./config.js');
const usage = require('./usage.js');
const postCmd = argv.postCmd || config.postCmd;
const profile = argv.profile || argv.p;
if (argv.help || argv.h) {
console.log(usage);
return;
}
if (argv.list || argv.l) {
swm.printDevices();
return;
}
let selectedMonitors = argv._;
if (profile) {
if (!config.profiles[profile]) {
throw Error(`profile ${profile} not found in config`);
}
selectedMonitors = config.profiles[profile];
console.log('Using profile', profile);
}
swm.activate(selectedMonitors, postCmd);