@s-hiroshi/bks
Version:
Cli bookmarks application
44 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Controller = void 0;
const open = require("open");
const parseSite_1 = require("../service/parseSite");
class Controller {
constructor(reader, writer, historyWriter, controlRepository) {
this.reader = reader;
this.writer = writer;
this.historyWriter = historyWriter;
this.controlRepository = controlRepository;
}
async run(args) {
const [command, query, ...subQeuries] = args;
if (!command) {
const control = this.controlRepository.find("help");
control?.execute();
return;
}
const control = this.controlRepository.find(command);
if (control != undefined) {
try {
const result = await control.execute(query);
if (typeof result === "string") {
open((0, parseSite_1.parseSite)(result));
this.historyWriter.write(result);
}
}
catch (e) {
console.log(e.message);
}
return;
}
if (!(0, parseSite_1.parseSite)(args[0])) {
console.log("Not Domain");
}
else {
open((0, parseSite_1.parseSite)(args[0]));
this.historyWriter.write(args[0]);
}
}
}
exports.Controller = Controller;
//# sourceMappingURL=controller.js.map