diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 09a7123..aafa527 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -445,6 +445,18 @@ int showMenu(List menuOptions, String menuName, [String menuInfo = ""]) } } +void printPubkeys(Set pubkey) { + if( pubkey.length == 1) { + print("There is 1 public key for the given name, which is: "); + } else { + print("There are ${pubkey.length} public keys for the given name, which are: "); + + } + print("${myPadRight("pubkey",64)} ${myPadRight("name", 20)} ${myPadRight("about", 40)}"); + pubkey.forEach( (x) => print("$x ${myPadRight(getAuthorName(x), 20)} ${myPadRight(gKindONames[x]?.about??"", 40)}")); + print(""); +} + Future otherOptionsMenuUi(Store node) async { bool continueOtherMenu = true; while(continueOtherMenu) { @@ -472,8 +484,9 @@ Future otherOptionsMenuUi(Store node) async { String userName = $tempUserName??""; if( userName != "") { Set pubkey = getPublicKeyFromName(userName); - print("There are ${ pubkey.length} public keys for the given name, which are/is: "); - pubkey.forEach( (x) => print(" $x : ${getNip05Name(x)} ")); + + printPubkeys(pubkey); + if( pubkey.length > 1) { if( pubkey.length > 1) { printWarning("Got multiple users with the same name. Try again, and/or type a more unique name or their full public keys."); @@ -532,8 +545,9 @@ Future otherOptionsMenuUi(Store node) async { String userName = $tempUserName??""; if( userName != "") { Set pubkey = getPublicKeyFromName(userName); - print("There are ${ pubkey.length} public keys for the given name, which are/is: "); - pubkey.forEach( (x) => print(" $x : ${getNip05Name(x)} ")); + + printPubkeys(pubkey); + if( pubkey.length > 1) { if( pubkey.length > 1) { printWarning("Got multiple users with the same name. Try again, and type a more unique name or id-prefix"); diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 85c3052..c03ec75 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -54,6 +54,17 @@ Map< String, List> > gReactions = {}; // is updated as kind 3 events are received Map< String, List> gContactLists = {}; +String myPadRight(String str, int width) { + String newStr = ""; + + if( str.length < width) { + newStr = str.padRight(width); + } else { + newStr = str.substring(0, width); + } + return newStr; +} + // returns tags as string that can be used to calculate event has. called from EventData constructor String getStrTagsFromJson(dynamic json) { String str = "";