Re: mailgw argument parsing

Ralf Schlatterbeck <[email protected]> Thu, 24 Nov 2022 09:49:32 +0100
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
On Wed, Nov 23, 2022 at 05:54:53PM -0500, John P. Rouillard wrote:
> 
> Positional args! raa raa raa!!! (raa is a cheer 8-)).
:-)

> The best of both worlds would be similar svn or git (can't believe I
> just typed that).
> 
>   command --global-options subcommand --sub-command-options

I agree this would be nicer. If we're going for backward compatibility I
fear this is not an option (pun intended).

> and so on. (Yes, I know that -I is required, there is a bug about how
> argparse help reports required args.)

What do you think about putting the argument of the current -I option
into another file in the oauth directory. That way we remove the only
required option (i.e. a non-optional option wich is a contradiction .-)

all the others have suitable defaults and we could keep these as real
"options" knowing that it is not so nice that they apply only to a
single sub-command. Note that they probably *would* apply to another
subcommand if we ever implement pop3_oauth.

> I guess my opposition just comes down to mixing arguments for one
> subcommand into the global arguments seems icky.  Similar to how
> mixing the transfer/authentication mechanism into the source protocol
> (imaps_cram, or pop vs pops ...)  was expedient but ... seemed off
> somehow.

Yes I agree. On the other hand having two optional positional parameters
(considering we get rid of the -I option as outlined above) is really
something that *should* be done with options in the classical sense.
I've made sure all the oauth specific options start with oauth...

> As an aside, it would be nice to be able to configure the path to
> .netrc. Currently it is stuck at ~roundupuser/.netrc.

I think .netrc is a mechanism from the early days of computing which
doesn't have this option (there is a netrc module in python and I doubt
it allows setting the file path). It may be nicer to think about a
general config-file for mailgw, something like
server=...
username=
password=
oauth-something= (or better us '_'?)

and add an option to read that file instead of specifying everything on
the command line. That would also get rid of my concerns about position
dependence. And you could have different config-files for different
invocations of mailgw. Or use different sections in the config-file and
specify the section? But this would be a lot of effort in a place where
I think we can live with some awkwardness of the interface because it is
configure-once...

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [email protected]