welsonjs/shoutcut.js

32 lines
770 B
JavaScript
Raw Permalink Normal View History

2023-12-18 21:47:48 +00:00
// shoutcut.js
// Namhyeon Go <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs
2020-11-20 08:44:50 +00:00
var SHELL = require("lib/shell");
var SYS = require("lib/system");
2020-11-18 10:55:06 +00:00
2022-11-06 10:00:42 +00:00
function main(args) {
2020-11-18 10:55:06 +00:00
if (args.length < 1) {
2021-08-10 16:45:26 +00:00
console.error("arguments could not be empty")
2020-11-18 10:55:06 +00:00
return;
}
2021-08-16 15:34:46 +00:00
var FN = args[0];
var target = require(FN);
2021-08-10 16:45:26 +00:00
2021-08-16 15:34:46 +00:00
if ("onShoutcut" in target) {
console.log("Trying execute onShoutcut:", FN);
while (true) {
try {
target.onShoutcut(args.slice(1));
} catch (e) {
console.error("onShoutcut ->", e.message);
target.onShoutcut(args.slice(1));
}
}
} else {
console.error("onShoutcut not defined");
}
2020-11-18 10:55:06 +00:00
};
2022-11-06 10:00:42 +00:00
exports.main = main;