Skip to content

Commit

Permalink
Add msmtp and msmtpq parsers
Browse files Browse the repository at this point in the history
I created this script to help me test out this change:
<https://gist.github.com/Jayman2000/30fb19578ad2dd978b9420b9739ec915>
  • Loading branch information
Jayman2000 committed Sep 6, 2023
1 parent 5e0956b commit eccb2a0
Showing 1 changed file with 132 additions and 0 deletions.
132 changes: 132 additions & 0 deletions resholve
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,138 @@ class ExternalCommandParsers(object):

return (generic,)

@staticmethod
def _msmtp():
"""
This was based on running "msmtp --help" with msmtp v1.8.24.
"""
generic = CommandParser("msmtp")

# General options
generic.add_argument(
"--version"
"--help",
"-P", "--pretend",
"-v", "-d", "--debug",
action="store_true"
)

# Changing the mode of operation
generic.add_argument("--configure", nargs=1)
generic.add_argument("-S", "--serverinfo", action="store_true")
generic.add_argument("--rmqs", nargs=1)

# Configuration options
generic.add_argument("-C", "--file", nargs=1)
# For msmtp, "-a" is nargs=1.
# For msmtpq, "--q-mgmt -a" is nargs=0.
generic.add_argument("-a", nargs="?")
generic.add_argument(
"--account",
"--host",
"--port",
nargs=1
)
generic.add_argument(
"--source-ip",
"--proxy-host",
"--proxy-port",
"--socket",
"--timeout",
"--protocol",
"--domain",
"--auth",
"--user",
nargs="?"
)
generic.add_argument(
"--passwordeval",
dest="commands",
action="invocations",
nargs=1
)
generic.add_argument(
"--tls",
"--tls-starttls",
"--tls-trust-file",
"--tls-crl-file",
"--tls-fingerprint",
"--tls-certcheck",
"--tls-key-file",
"--tls-cert-file",
"--tls-priorities",
"--tls-host-override",
"--tls-min-dh-prime-bits",
nargs="?"
)

# Options specific to sendmail mode
generic.add_argument(
"--auto-from",
"-f", "--from=address",
"--maildomain",
"-N", "--dsn-notify",
"-R", "--dsn-return",
"-X", "--logfile",
"--logfile-time-format",
"--syslog",
nargs="?"
)
generic.add_argument(
"-t", "--read-recipients",
"--read-envelope-from",
action="store_true"
)
generic.add_argument(
"--aliases",
"--set-from-header",
"--set-date-header",
"--set-msgid-header",
"--remove-bcc-headers",
"--undisclosed-recipients",
nargs="?"
)
# Accepted but ignored:
generic.add_argument("-A", action="store_true")
generic.add_argument("-B", nargs=1)
generic.add_argument("-bm", action="store_true")
generic.add_argument("-F", nargs=1)
generic.add_argument("-G", action="store_true")
# For msmtp, "-h" is nargs=1.
# For msmtpq "--q-mgmt -h" is nargs=0.
generic.add_argument("-h", nargs="?")
generic.add_argument("-i", action="store_true")
generic.add_argument("-L", nargs=1)
generic.add_argument(
"-m",
"-n",
action="store_true"
)
generic.add_argument(
"-O",
"-o",
nargs=1
)

return (generic,)

@classmethod
def _msmtpq(cls):
"""
This was based on running "msmtpq --q-mgmt -h" with msmtp v1.8.24.
"""
generic = cls._msmtp()[0]

# -R, -d, -a and -h are already handled by the msmtp parser.
generic.add_argument(
"--q-mgmt",
"-r",
"-p",
action="store_true"
)

return (generic,)


def generate_builtin_command_parser(cmdname):
cmdname = "_" + cmdname
Expand Down

0 comments on commit eccb2a0

Please sign in to comment.