mailgw argument parsing

Ralf Schlatterbeck <[email protected]> Mon, 21 Nov 2022 15:28:39 +0100
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
I'm in the process of adding OAUTH support to roundup-mailgw.

Now the current argument parsing in mailgw uses getopt.getopt for
argument parsing. I'd like to move this to argparse.ArgumentParser when
at it (I need to add at least one new option).

There is a -c option to set the Class we're acting on, defaulting to
MAIL_DEFAULT_CLASS (in the config-file default_class in section [mailgw])

The -C and -S options to mailgw are used to set properties on a class,
-C accepts the values 'file', 'issue', 'msg', 'user' and defaults to 'msg'.
Note that even if a -c option is present, setting the default class to
something other than 'issue' the -C option will insist on 'issue'. At
least that's how I understand the code.

So to set several properties on e.g. issue and user you would use

-C issue -S issueprop1=value1 -S issueprop2=value2 -C user -S userprop=uvalue

This interleaving of -C and -S options is not only un-intuitive for
users (well, at least for me) but is fundamentally incompatible with how
ArgumentParser works.

So I'd suggest we change this to only a -S (--set-value) option that
optionally takes a classname before a '.', the above would become:

-S issue.issueprop1=value1 -S issue.issueprop2=value2 -S user.userprop=uvalue

Note that this will not become much longer if not many properties are
set for a class as can be seen above (I did not construct this to be the
same length). When leaving out the classname, the default would be msg
as it used to be.

What do you think?

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