-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5433cc9
commit 5d1b3c8
Showing
14 changed files
with
595 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Args, Command, Flags, Interfaces } from "@oclif/core"; | ||
import { Configuration, getConfiguration } from "../utils/config.js"; | ||
|
||
//// | ||
/// Types | ||
// | ||
|
||
export type Flags<T extends typeof Command> = Interfaces.InferredFlags< | ||
(typeof ImportBaseCommand)["baseFlags"] & T["flags"] | ||
>; | ||
|
||
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>; | ||
|
||
//// | ||
/// Exports | ||
// | ||
|
||
export const importNameArg = { | ||
importName: Args.string({ | ||
required: true, | ||
name: "APINAME", | ||
}), | ||
}; | ||
|
||
export abstract class ImportBaseCommand<T extends typeof Command> extends Command { | ||
static override baseFlags = {}; | ||
|
||
static override flags = { | ||
year: Flags.string({ | ||
char: "y", | ||
summary: "Year to import", | ||
default: `${new Date().getFullYear()}`, | ||
}), | ||
output: Flags.string({ | ||
char: "o", | ||
summary: "Path to output CSV", | ||
default: "", | ||
}), | ||
date: Flags.string({ | ||
summary: "Date used for filtering", | ||
default: "", | ||
}), | ||
}; | ||
|
||
protected flags!: Flags<T>; | ||
protected args!: Args<T>; | ||
protected conf!: Configuration; | ||
|
||
public override async init(): Promise<void> { | ||
await super.init(); | ||
const { args, flags } = await this.parse({ | ||
flags: this.ctor.flags, | ||
baseFlags: (super.ctor as typeof ImportBaseCommand).baseFlags, | ||
enableJsonFlag: this.ctor.enableJsonFlag, | ||
args: this.ctor.args, | ||
strict: true, | ||
}); | ||
|
||
this.flags = flags as Flags<T>; | ||
this.args = args as Args<T>; | ||
this.conf = getConfiguration(); | ||
} | ||
|
||
protected override async catch(err: Error & { exitCode?: number }) { | ||
await super.catch(err); | ||
} | ||
|
||
protected override async finally(_: Error | undefined) { | ||
await super.finally(_); | ||
} | ||
} |
Oops, something went wrong.