From 21a09970791c261cbb801b28042cff043c150f0d Mon Sep 17 00:00:00 2001 From: redpeacock78 Date: Fri, 12 Nov 2021 21:56:15 +0900 Subject: [PATCH] chore: Change cli.ts --- cli.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cli.ts b/cli.ts index 25b716c..eda0e51 100644 --- a/cli.ts +++ b/cli.ts @@ -6,21 +6,25 @@ try { let file: Uint8Array; let stdin: Uint8Array; let filled: boolean; + let args_judge: boolean; const isatty: boolean = Deno.isatty(Deno.stdin.rid); if (!isatty) { stdin = getStdinBufferSync({ exitOnEnter: false }); filled = stdin.length !== 0 ? true : false; } else if (Deno.args[0] !== undefined) { - if (!Deno.args[0].match(/-d|--decode|-h|--help|-V|--version/)) { + args_judge = Deno.args[0].match(/-d|--decode|-h|--help|-V|--version/) ? true : false; + if (!args_judge) { try { - file = Deno.readFileSync(Deno.args[0]); + file = Deno.readAllSync(Deno.openSync(Deno.args[0])); + Deno.close(Deno.openSync(Deno.args[0]).rid); filled = file.length !== 0 ? true : false; } catch { throw new Error("base85: No such file or directory"); } } else if (Deno.args[1]) { try { - file = Deno.readFileSync(Deno.args[1]); + file = Deno.readAllSync(Deno.openSync(Deno.args[1])); + Deno.close(Deno.openSync(Deno.args[1]).rid); filled = file.length !== 0 ? true : false; } catch { throw new Error("base85: No such file or directory"); @@ -30,15 +34,15 @@ try { const { options, args } = await new Command() .name("base85") .description("Base85 (Ascii85 with Adobe Escape Sequence) encode or decode FILE, or standard input, to standard output.") - .version("0.0.8") + .version("0.0.9") .option("-d, --decode", "Decode data") .arguments("