Add --help command

This commit is contained in:
Franck Royer 2021-05-19 12:07:48 +10:00
parent 2ea17bfdfa
commit 90e224577f
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 19 additions and 1 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Implement [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
- Expose `Direction` enum from js-waku root (it was only accessible via the proto module).
- Examples (cli chat): Use light push to send messages if `--lightPush` is passed.
- Examples (cli chat): Print usage if `--help` is passed.
## [0.4.0] - 2021-05-18

View File

@ -20,6 +20,8 @@ const ChatContentTopic = 'dingpu';
export default async function startChat(): Promise<void> {
let opts = processArguments();
if (!opts) return;
if (opts.autoDial) {
opts = await addFleetNodes(opts);
}
@ -132,7 +134,7 @@ interface Options {
lightPush: boolean;
}
function processArguments(): Options {
function processArguments(): Options | null {
const passedArgs = process.argv.slice(2);
let opts: Options = {
@ -146,6 +148,21 @@ function processArguments(): Options {
while (passedArgs.length) {
const arg = passedArgs.shift();
switch (arg) {
case `--help`:
console.log('Usage:');
console.log(' --help This help message');
console.log(
' --staticNode {multiaddr} Connect to this static node, can be set multiple time'
);
console.log(' --listenAddr {addr} Listen on this address');
console.log(' --autoDial Automatically dial Status fleet nodes');
console.log(
' --prod With `autoDial`, connect ot Status prod fleet (test fleet is dialed if not set)'
);
console.log(
' --lightPush Use Waku v2 Light Push protocol to send messages, instead of Waku v2 relay'
);
return null;
case '--staticNode':
opts.staticNodes.push(multiaddr(passedArgs.shift()!));
break;