From a Slack discussion:
try and authentication with PLAIN mech and observe the error within the driver via the call to opts.ConnString.Validate() .
$ ./bin/mongotop --host localhost --port 27017 --authenticationMechanism PLAIN --ssl --username admin 5
Enter password for mongo user:
2023-02-06T12:20:39.949-0500 error parsing command line options: password required for PLAIN
2023-02-06T12:20:39.949-0500 try 'mongotop --help' for more information
The password provided to the prompt should be used.
John proposed this patch:
But from discussion in Slack, this may not be right:
I’m not sure it is [right]. We shouldn’t check if we need to prompt for the password before we parse the connstring. Otherwise we ignore passwords set in the connstring. I think the correct solution here is to set the password in the connstring as well as the opts once we get it from the prompt.