mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
Use factory pattern for yargs
The ESM import of yargs does not support the singleton way of using yargs, instead we have to call the yargs function to get a parser that can be augmented with the options. The .argv property has also been deprecated. Replace it with a call to .parse() instead.
This commit is contained in:
1 parent
7987a5d925
commit
d6dce12acc
4 files changed
+8
-8
No files matched your search
@@ -268,7 +268,7 @@ interface InitializeParameters {
|
||||
|
||||
async function initialize(): Promise<InitializeParameters> {
|
||||
// argument parsing
|
||||
const args = await yargs
|
||||
const args = await yargs(process.argv.slice(2))
|
||||
.scriptName("controller")
|
||||
.usage("$0 <command> [options]")
|
||||
.option("log-level", {
|
||||
@@ -340,7 +340,7 @@ async function initialize(): Promise<InitializeParameters> {
|
||||
})
|
||||
.demandCommand(1, "You need to specify a command to run")
|
||||
.strict()
|
||||
.argv
|
||||
.parse()
|
||||
;
|
||||
|
||||
// Combined log stream of the whole cluster.
|
||||
|
||||
@@ -750,7 +750,7 @@ async function inquirerMissingArgs(args) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let args = yargs
|
||||
let yarg = yargs(process.argv.slice(2))
|
||||
.option("log-level", {
|
||||
nargs: 1, describe: "Log level to print to stdout", default: "info",
|
||||
choices: ["none"].concat(Object.keys(levels)), type: "string",
|
||||
@@ -805,14 +805,14 @@ async function main() {
|
||||
;
|
||||
|
||||
if (process.platform === "linux") {
|
||||
args = args
|
||||
yarg = yarg
|
||||
.option("allow-install-as-root", {
|
||||
nargs: 0, describe: "(Linux only) Allow installing as root (not recommended)", type: "boolean",
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
args = args.argv;
|
||||
const args = yarg.parse();
|
||||
|
||||
setLogLevel(args.logLevel === "none" ? -1 : levels[args.logLevel]);
|
||||
dev = args.dev;
|
||||
|
||||
@@ -82,7 +82,7 @@ export class HostConnector extends lib.WebSocketClientConnector {
|
||||
async function startHost() {
|
||||
// argument parsing
|
||||
// eslint-disable-next-line node/no-sync
|
||||
const args = yargs
|
||||
const args = yargs(process.argv.slice(2))
|
||||
.scriptName("host")
|
||||
.usage("$0 <command> [options]")
|
||||
.option("log-level", {
|
||||
|
||||
@@ -121,7 +121,7 @@ async function build(args) {
|
||||
|
||||
|
||||
async function main() {
|
||||
const args = yargs
|
||||
const args = yargs(process.argv.slice(2))
|
||||
.scriptName("build")
|
||||
.options({
|
||||
"clean": { describe: "Remove previous builds", type: "boolean", default: false },
|
||||
@@ -144,7 +144,7 @@ async function main() {
|
||||
},
|
||||
})
|
||||
.strict()
|
||||
.argv
|
||||
.parse()
|
||||
;
|
||||
|
||||
await build(args);
|
||||
|
||||
Reference in new issue
Block a user