Unfortunately kingpin doesn't support natively support aliased flag names, so
you can supply both --start-tls and --starttls without an error, but that's
just "holding it wrong".
I found some servers don't always return a space after the three-digit code
for example,
certigo connect --start-tls ftp ftp.mirrorservice.org:21
error connecting: FTP server responded with status 220-----------------------------------------------------------------------------
, was expecting 220
Instead, we always take the first three digits and parse them as an integer, rather than
relying on the space. Makes the code look a little cleaner too, by returning it as an int.
If otherwise unspecified, default to port 443.
If a starttls protocol is given, use a protocol-specific default.
So now "certigo connect squareup.com" works.
This moves two functions out of main.go.
The only change to the functions was to make them take arguments, instead of using global variables in main.
The mysql and psql imports are moved here too.