From 90e224577f3c1e0b87cd84add5cac5d89f189c4c Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 19 May 2021 12:07:48 +1000 Subject: [PATCH] Add `--help` command --- CHANGELOG.md | 1 + examples/cli-chat/src/chat.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9ca06ea9..05a719b61e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/examples/cli-chat/src/chat.ts b/examples/cli-chat/src/chat.ts index 0ebdc3bb97..853f364e93 100644 --- a/examples/cli-chat/src/chat.ts +++ b/examples/cli-chat/src/chat.ts @@ -20,6 +20,8 @@ const ChatContentTopic = 'dingpu'; export default async function startChat(): Promise { 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;