From 1a08202ae228a94df5c4b759f7665d9e29af62f2 Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Sat, 22 Oct 2022 21:00:45 +0800 Subject: [PATCH] refactor: move help out --- s3si.ts | 18 +++++++++++++++++- src/app.ts | 18 ++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/s3si.ts b/s3si.ts index 5a79401..d9897c9 100644 --- a/s3si.ts +++ b/s3si.ts @@ -16,8 +16,24 @@ const parseArgs = (args: string[]) => { return parsed; }; +const opts = parseArgs(Deno.args); +if (opts.help) { + console.log( + `Usage: deno run -A ${Deno.mainModule} [options] + +Options: + --profile-path , -p Path to config file (default: ./profile.json) + --exporter , -e Exporter list to use (default: stat.ink) + Multiple exporters can be separated by commas + (e.g. "stat.ink,file") + --no-progress, -n Disable progress bar + --help Show this help message and exit`, + ); + Deno.exit(0); +} + const app = new App({ ...DEFAULT_OPTS, - ...parseArgs(Deno.args), + ...opts, }); await showError(app.run()); diff --git a/src/app.ts b/src/app.ts index 02088a1..65a719f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -23,14 +23,14 @@ export type Opts = { profilePath: string; exporter: string; noProgress: boolean; - help?: boolean; + monitor: boolean; }; export const DEFAULT_OPTS: Opts = { profilePath: "./profile.json", exporter: "stat.ink", noProgress: false, - help: false, + monitor: false, }; /** @@ -158,20 +158,6 @@ export class App { state: State = DEFAULT_STATE; constructor(public opts: Opts) { - if (this.opts.help) { - console.log( - `Usage: deno run -A ${Deno.mainModule} [options] - -Options: - --profile-path , -p Path to config file (default: ./profile.json) - --exporter , -e Exporter list to use (default: stat.ink) - Multiple exporters can be separated by commas - (e.g. "stat.ink,file") - --no-progress, -n Disable progress bar - --help Show this help message and exit`, - ); - Deno.exit(0); - } } async writeState(newState: State) { this.state = newState;