Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update cli options with basepath and version #380

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ Options:
Provide the hostname to serve the server (default: "0.0.0.0")
* `--template <file>`
Provide the html template for the applets (default: "./applet_template.html")
* `--basepath <string>`
env: **BASEPATH**
specify the basepath for all APIs (default: "")
* `-D, --debug`
env: **DEBUG**
debug (default: false)
* `-v, --version`
show version number


**[🔝 back to top](#toc)**

Expand Down
35 changes: 19 additions & 16 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ program
.default('0.0.0.0')
.argParser((h) => {
if (h.includes('/')) {
L.error(`${bad} ${h} is not a valid hostname, subpath should be specified using --basepath option`);
L.error(
`${bad} ${h} is not a valid hostname, subpath should be specified using --basepath option`
);
process.exit(0);
}
return h;
Expand All @@ -93,21 +95,22 @@ program
)
)
.addOption(new Option('-D, --debug', 'debug').env('DEBUG').default(false).argParser(Boolean))
.addOption(new Option('--basepath <string>', 'specify the basepath for all APIs')
.env('BASEPATH')
.default('')
.argParser((b) => {
if ( b === '') return b;
if (!b.startsWith('/')) {
L.error(`${bad} ${b} is not a valid subpath, should start with a '/'`);
process.exit(0);
}
if(b.endsWith('/')) {
L.error(`${bad} ${b} is not a valid subpath, should not end with a '/'`);
process.exit(0);
}
return b;
})
.addOption(
new Option('--basepath <string>', 'specify the basepath for all APIs')
.env('BASEPATH')
.default('')
.argParser((b) => {
if (b === '') return b;
if (!b.startsWith('/')) {
L.error(`${bad} ${b} is not a valid subpath, should start with a '/'`);
process.exit(0);
}
if (b.endsWith('/')) {
L.error(`${bad} ${b} is not a valid subpath, should not end with a '/'`);
process.exit(0);
}
return b;
})
)
.version(data.version, '-v, --version')
.addHelpText(
Expand Down