mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 10:55:06 -05:00
Add usage message to development server
This commit is contained in:
parent
aef2812348
commit
07c9cdebb6
2 changed files with 22 additions and 3 deletions
|
@ -67,6 +67,8 @@ can be used. For instance, to run gamja on Libera Chat:
|
|||
npm install --include=dev
|
||||
npm start -- irc.libera.chat
|
||||
|
||||
See `npm start -- -h` for a list of options.
|
||||
|
||||
### Production build
|
||||
|
||||
Optionally, [Parcel] can be used to build a minified version of gamja.
|
||||
|
|
|
@ -6,14 +6,31 @@ import { WebSocketServer } from "ws";
|
|||
|
||||
const WS_BAD_GATEWAY = 1014;
|
||||
|
||||
const usage = `usage: [options...] [host]
|
||||
|
||||
Starts an HTTP server delivering static files. If [host] is specified, the
|
||||
server will proxy WebSocket connections to the specified remote IRC server.
|
||||
|
||||
Options:
|
||||
-p <port> Listening port (default: 8080)
|
||||
-h Show help message
|
||||
`;
|
||||
|
||||
let localPort = 8080;
|
||||
let remoteHost;
|
||||
let remotePort = 6697;
|
||||
|
||||
let args = process.argv.slice(2);
|
||||
if (args[0] === "-p") {
|
||||
localPort = parseInt(args[1], 10);
|
||||
args = args.slice(2);
|
||||
while (args.length > 0 && args[0].startsWith("-")) {
|
||||
switch (args[0]) {
|
||||
case "-p":
|
||||
localPort = parseInt(args[1], 10);
|
||||
args = args.slice(2);
|
||||
break;
|
||||
default:
|
||||
console.log(usage);
|
||||
process.exit(args[0] === "-h" ? 0 : 1);
|
||||
}
|
||||
}
|
||||
remoteHost = args[0];
|
||||
|
||||
|
|
Loading…
Reference in a new issue