From 08180c00a8d0037046e398a37e48b7f5a45e26d6 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Wed, 21 Dec 2022 11:11:17 +0530 Subject: [PATCH] printed relay list in every case at start --- bin/nostr_console.dart | 10 ++++------ lib/utils.dart | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bin/nostr_console.dart b/bin/nostr_console.dart index c46086a..ed970db 100644 --- a/bin/nostr_console.dart +++ b/bin/nostr_console.dart @@ -115,7 +115,7 @@ Future main(List arguments) async { // write informative message in case user is not using proper keys if( userPublicKey == gDefaultPublicKey) { print("You should ideally create your own private key and use it with ${gWarningColor}--prikey$gColorEndMarker program argument. "); - print("Create a private key from ${gWarningColor}astral.ninja, @damusapp or anigma.io, or even from command line using `openssl rand -hex 32`.$gColorEndMarker.\n"); + print("Create a private key from ${gWarningColor}astral.ninja, @damusapp, or even from command line using `openssl rand -hex 32`.$gColorEndMarker.\n"); } // handle relay related argument @@ -126,7 +126,7 @@ Future main(List arguments) async { if(relay.startsWith(RegExp(r'^ws[s]?:\/\/'))) { parsedRelays.add(relay); } else { - print("The provided relay entry: $relay does not start with ws:// or wss://, omitting"); + printWarning("The provided relay entry: \"$relay\" does not start with ws:// or wss://, omitting"); } }); @@ -136,10 +136,9 @@ Future main(List arguments) async { } else { print("No valid relays were provided, using the default relay list"); } - - print("Relay List: ${gListRelayUrls1}"); } - + printSet( gListRelayUrls1, "Relay List: "); + if( argResults[lastdaysArg] != null) { gNumLastDays = int.parse(argResults[lastdaysArg]); print("Going to show posts for last $gNumLastDays days"); @@ -156,7 +155,6 @@ Future main(List arguments) async { try { var terminalColumns = gDefaultTextWidth; - if( stdout.hasTerminal ) terminalColumns = stdout.terminalColumns; diff --git a/lib/utils.dart b/lib/utils.dart index e5556d2..3f11bd9 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -384,3 +384,19 @@ String getMultiUserRequest(String subscriptionId, Set publicKeys, int nu s = getJsonList(publicKeys); return strSubscription1 + s + strSubscription2; } + +// ends with a newline +void printSet( Set toPrint, [ String prefix = ""]) { + stdout.write(prefix); + + int i = 0; + toPrint.forEach((element) { + if( i != 0) { + stdout.write(", "); + } + + stdout.write(element); + i++; + }); + stdout.write("\n"); +}