Add --version flag

This commit is contained in:
Kallum Jones 2022-08-09 23:17:08 +01:00
parent 47838309af
commit 5868bdc066
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9

View File

@ -17,6 +17,7 @@ import MigrateCommand from "./commands/migrate_command.js";
import ModrinthSource from "./mods/sources/modrinth_source.js"; import ModrinthSource from "./mods/sources/modrinth_source.js";
import Mods from "./mods/mods.js"; import Mods from "./mods/mods.js";
import {CurseforgeSource} from "./mods/sources/curseforge_source.js"; import {CurseforgeSource} from "./mods/sources/curseforge_source.js";
import MinecraftUtils from "./util/minecraft_utils.js";
export default class ModManager { export default class ModManager {
public static logger: Logger | null = null; public static logger: Logger | null = null;
@ -40,14 +41,16 @@ export default class ModManager {
new MigrateCommand() new MigrateCommand()
]; ];
static init() { static async init() {
if (Initialiser.isInitialised()) { if (Initialiser.isInitialised()) {
this.logger = ModManager.createLogger(); this.logger = ModManager.createLogger();
} }
this.program this.program
.name('mod-manager') .name('mod-manager')
.description('A package (mod) manager for Fabric Minecraft Servers'); .description('A package (mod) manager for Fabric Minecraft Servers')
.version(`Minecraft server version: ${await MinecraftUtils.getCurrentMinecraftVersion()}`, "-v, --version", "Reports the version of the Minecraft server");
for (const command of this.subcommands) { for (const command of this.subcommands) {
command.registerCommand(this.program); command.registerCommand(this.program);
@ -58,6 +61,7 @@ export default class ModManager {
this.program.showSuggestionAfterError(); this.program.showSuggestionAfterError();
this.program.showHelpAfterError(); this.program.showHelpAfterError();
this.program.parse(); this.program.parse();
} }