Skip to content

Commit

Permalink
convert "schwarz.mailqueue.cli" into package
Browse files Browse the repository at this point in the history
I am planning to add more cli scripts and putting all of that code into
a single module is less readable.
  • Loading branch information
FelixSchwarz committed Aug 5, 2024
1 parent b74fa55 commit 18eece3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
3 changes: 3 additions & 0 deletions schwarz/mailqueue/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

from .one_shot_queue_run import *
from .send_test_message import *
32 changes: 32 additions & 0 deletions schwarz/mailqueue/cli/one_shot_queue_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT

import sys

import docopt

from ..queue_runner import one_shot_queue_run


__all__ = [
'one_shot_queue_run_main',
]

def one_shot_queue_run_main(argv=sys.argv, return_rc_code=False):
"""mq-run.
Usage:
mq-run [options] <config> <queue_dir>
Options:
--verbose -v more verbose program output
"""
arguments = docopt.docopt(one_shot_queue_run_main.__doc__, argv=argv[1:])
config_path = arguments['<config>']
queue_dir = arguments['<queue_dir>']
cli_options = {
'verbose': arguments['--verbose'],
}
one_shot_queue_run(queue_dir, config_path, options=cli_options)
exit_code = 0
return exit_code if (return_rc_code) else sys.exit(exit_code)
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,13 @@

import docopt

from .mailflow_check import send_test_message
from .queue_runner import one_shot_queue_run
from ..mailflow_check import send_test_message


__all__ = [
'one_shot_queue_run_main',
'send_test_message_main',
]

def one_shot_queue_run_main(argv=sys.argv, return_rc_code=False):
"""mq-run.
Usage:
mq-run [options] <config> <queue_dir>
Options:
--verbose -v more verbose program output
"""
arguments = docopt.docopt(one_shot_queue_run_main.__doc__, argv=argv[1:])
config_path = arguments['<config>']
queue_dir = arguments['<queue_dir>']
cli_options = {
'verbose': arguments['--verbose'],
}
one_shot_queue_run(queue_dir, config_path, options=cli_options)
exit_code = 0
return exit_code if (return_rc_code) else sys.exit(exit_code)


def send_test_message_main(argv=sys.argv, return_rc_code=False):
"""mq-send-test.
Expand Down

0 comments on commit 18eece3

Please sign in to comment.