Skip to content

Commit

Permalink
fix(cli): disallow unknown options (#1079)
Browse files Browse the repository at this point in the history
* display choices for various options
* update incorrect types

Note: this prevents people/AI from using v3 options in v4 cli
  • Loading branch information
ayushmanchhabra committed May 9, 2024
1 parent be70eae commit 5d54d8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ nwbuild({

### Chores

- chore(cli): migrate from `yargs` to `commander`
- chore(get): verify sha checksum for downloads
- chore: annotate file paths as `fs.PathLike` instead of `string`.
- chore(bld): factor out core build step
Expand All @@ -314,7 +313,6 @@ nwbuild({
- chore(bld): factor out compressing
- chore(bld): factor out managed manifest
- chore(bld): move `.desktop` entry file logic to `create-desktop-shortcuts` package
- chore(util): factor out file paths as constant variables

## FAQ

Expand Down
11 changes: 9 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const cli = yargs(yargs_helpers.hideBin(process.argv))
.command("[srcDir] [options]")
.option("mode", {
type: "string",
description: "`run` or `build` application",
description: "`get`, `run` or `build` application",
choices: ["get", "run", "build"]
})
.option("version", {
type: "string",
Expand All @@ -21,14 +22,17 @@ const cli = yargs(yargs_helpers.hideBin(process.argv))
.option("flavor", {
type: "string",
description: "NW.js build flavor",
choices: ["normal", "sdk"]
})
.option("platform", {
type: "string",
description: "NW.js supported platform",
choices: ["linux", "osx", "win"]
})
.option("arch", {
type: "string",
description: "NW.js supported architecture",
choices: ["ia32", "x64", "arm64"]
})
.option("outDir", {
type: "string",
Expand Down Expand Up @@ -61,15 +65,18 @@ const cli = yargs(yargs_helpers.hideBin(process.argv))
.option("zip", {
type: "string",
description: "Flag to enable/disable compression",
choices: ["zip", "tar", "tgz"]
})
.option("ffmpeg", {
type: "string",
type: "boolean",
description: "Flag to enable/disable downloading community ffmpeg",
})
.option("logLevel", {
type: "string",
description: "Specify log level",
choices: ["error", "warn", "info", "debug"]
})
.strictOptions()
.parse();

nwbuild({
Expand Down

0 comments on commit 5d54d8c

Please sign in to comment.