Add Ctrl + C support

This commit is contained in:
2023-05-20 09:44:13 +08:00
parent fbe7b66e32
commit f0b032e948
3 changed files with 31 additions and 4 deletions

10
main.ts
View File

@@ -1,7 +1,7 @@
import { parse } from "https://deno.land/[email protected]/flags/mod.ts";
import { load_settings } from "./config.ts";
import { check_file_permissions } from "./permissons.ts";
import { TaskManager } from "./task_manager.ts";
import { AlreadyClosedError, TaskManager } from "./task_manager.ts";
import { ParsedUrl, parseUrl, UrlType } from "./url.ts";
import { sure_dir } from "./utils.ts";
@@ -75,10 +75,12 @@ async function run() {
async function main() {
await sure_dir(settings.base);
if (cmd == CMD.Download) {
download();
await download();
} else if (cmd == CMD.Run) {
run();
await run();
}
}
main();
main().catch((e) => {
if (!(e instanceof AlreadyClosedError)) throw e;
});