Files
workavia-drive/twake/backend/node/src/cli/index.ts
T
montaghanmy 10fe6f78d1 feat: init
2023-03-23 11:03:16 +01:00

29 lines
725 B
TypeScript

import yargs from "yargs";
import { logger } from "../core/platform/framework/logger";
process.env.NODE_ENV = "cli";
yargs
.strict()
.usage("Usage: $0 <command> [options]")
.middleware([
argv => {
logger.level = argv.verbose ? "debug" : "fatal";
},
])
.commandDir("cmds", {
visit: commandModule => commandModule.default,
})
.option("verbose", {
alias: "v",
default: false,
type: "boolean",
description: "Run with verbose logging",
})
.demandCommand(1, "Please supply a valid command")
.alias("help", "h")
.help("help")
.version()
.epilogue("for more information, go to https://twake.app")
.example("$0 <command> --help", "show help of the issue command").argv;