mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-10-11 03:42:34 +02:00
fix for issue #49 by exiting if too many wrong menu input given
> 40 for now
This commit is contained in:
@@ -448,6 +448,8 @@ int showMenu(List<String> menuOptions, String menuName, [String menuInfo = ""])
|
||||
if( valueOption >= 1 && valueOption <= menuOptions.length) {
|
||||
reAdjustAlignment(); // in case user has changed alignment
|
||||
print('You picked: $valueOption');
|
||||
// reset this
|
||||
gInvalidInputCount = 0;
|
||||
return valueOption;
|
||||
}
|
||||
}
|
||||
@@ -458,6 +460,13 @@ int showMenu(List<String> menuOptions, String menuName, [String menuInfo = ""])
|
||||
}
|
||||
}
|
||||
printWarning("\nInvalid option. Kindly try again. The valid options are from 1 to ${menuOptions.length}");
|
||||
gInvalidInputCount++;
|
||||
|
||||
if( gInvalidInputCount > gMaxInValidInputAccepted) {
|
||||
printWarning("The program has received an invalid input more than $gMaxInValidInputAccepted. There seems to be some problem etc, so exiting");
|
||||
exit(0);
|
||||
//programExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1576,3 +1585,12 @@ Future<void> mainMenuUi(Store node) async {
|
||||
} // end while
|
||||
} // end mainMenuUi()
|
||||
|
||||
|
||||
Future<void> programExit([String message= ""]) async {
|
||||
if( gEventsFilename != "") {
|
||||
await gStore?.writeEventsToFile(gEventsFilename);
|
||||
}
|
||||
print("In programexit");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user