Skip to content

Commit

Permalink
Bring back a long-form option for log verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunedan committed Apr 12, 2024
1 parent 5e3bb62 commit 1eb48c5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
5 changes: 5 additions & 0 deletions tests/test_echelon.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class TestArgumentParsing(TestCase):
Namespace(domain='lobby.wildfiregames.com', login='EcheLOn', xserver=None,
no_verify=False, nickname='RatingsBot', password='XXXXXX', room='arena',
verbosity=3, database_url='sqlite:///lobby_rankings.sqlite3')),
(['--verbosity', '3'],
Namespace(domain='lobby.wildfiregames.com', login='EcheLOn', xserver=None,
no_verify=False, nickname='RatingsBot', password='XXXXXX', room='arena',
verbosity=3, database_url='sqlite:///lobby_rankings.sqlite3')),
(['-m', 'lobby.domain.tld'],
Namespace(domain='lobby.domain.tld', login='EcheLOn', verbosity=0, nickname='RatingsBot',
xserver=None, no_verify=False, password='XXXXXX', room='arena',
Expand Down Expand Up @@ -169,6 +173,7 @@ def test_valid(self, cmd_args, expected_args):
@parameterized.expand([
(['-f'],),
(['--foo'],),
(['-v', '--verbosity', '1'],)
])
def test_invalid(self, cmd_args):
"""Test invalid parameter combinations."""
Expand Down
5 changes: 5 additions & 0 deletions tests/test_xpartamupp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class TestArgumentParsing(TestCase):
Namespace(domain='lobby.wildfiregames.com', login='xpartamupp', verbosity=3,
xserver=None, no_verify=False,
nickname='WFGBot', password='XXXXXX', room='arena')),
(['--verbosity', '3'],
Namespace(domain='lobby.wildfiregames.com', login='xpartamupp', verbosity=3,
xserver=None, no_verify=False,
nickname='WFGBot', password='XXXXXX', room='arena')),
(['-m', 'lobby.domain.tld'],
Namespace(domain='lobby.domain.tld', login='xpartamupp', verbosity=0, nickname='WFGBot',
xserver=None, no_verify=False, password='XXXXXX', room='arena')),
Expand Down Expand Up @@ -134,6 +138,7 @@ def test_valid(self, cmd_args, expected_args):
@parameterized.expand([
(['-f'],),
(['--foo'],),
(['-v', '--verbosity', '1'],)
])
def test_invalid(self, cmd_args):
"""Test invalid parameter combinations."""
Expand Down
13 changes: 10 additions & 3 deletions xpartamupp/echelon.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,15 @@ def parse_args():
"""
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="EcheLOn - XMPP Rating Bot")

verbosity_parser = parser.add_mutually_exclusive_group()
verbosity_parser.add_argument("-v", action="count", dest="verbosity", default=0,
help="Increase verbosity of logging. Can be provided up to "
"three times to get full debug logging")
verbosity_parser.add_argument("--verbosity", type=int,
help="Increase verbosity of logging. Supported values are 0 to 3"
)

parser.add_argument('-m', '--domain', help="XMPP server to connect to",
default='lobby.wildfiregames.com')
parser.add_argument('-l', '--login', help="username for login", default='EcheLOn')
Expand All @@ -815,12 +824,10 @@ def parse_args():
default='sqlite:///lobby_rankings.sqlite3')
parser.add_argument('-s', '--server', help='address of the ejabberd server',
action='store', dest='xserver', default=None)
parser.add_argument('-v', action="count", dest='verbosity', default=0,
help="Increase verbosity of logging. Can be provided up to three times to "
"get full debug logging")
parser.add_argument('--no-verify',
help="Don't verify the TLS server certificate when connecting",
action='store_true')

return parser.parse_args()


Expand Down
13 changes: 10 additions & 3 deletions xpartamupp/modbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,15 @@ def parse_args():
"""
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter,
description="ModBot - XMPP Moderation Bot")

verbosity_parser = parser.add_mutually_exclusive_group()
verbosity_parser.add_argument("-v", action="count", dest="verbosity", default=0,
help="Increase verbosity of logging. Can be provided up to "
"three times to get full debug logging")
verbosity_parser.add_argument("--verbosity", dest="verbosity", type=int,
help="Increase verbosity of logging. Supported values are 0 to 3"
)

parser.add_argument("-m", "--domain", help="XMPP server to connect to",
default="lobby.wildfiregames.com")
parser.add_argument("-l", "--login", help="username for login", default="modbot")
Expand All @@ -673,12 +682,10 @@ def parse_args():
default="sqlite:///lobby_moderation.sqlite3")
parser.add_argument("-s", "--server", help="address of the ejabberd server",
action="store", dest="xserver", default=None)
parser.add_argument('-v', action="count", dest='verbosity', default=0,
help="Increase verbosity of logging. Can be provided up to three times to "
"get full debug logging")
parser.add_argument("--no-verify",
help="Don't verify the TLS server certificate when connecting",
action="store_true")

return parser.parse_args()


Expand Down
13 changes: 10 additions & 3 deletions xpartamupp/xpartamupp.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,15 @@ def parse_args():
"""
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="XpartaMuPP - XMPP Multiplayer Game Manager")

verbosity_parser = parser.add_mutually_exclusive_group()
verbosity_parser.add_argument("-v", action="count", dest="verbosity", default=0,
help="Increase verbosity of logging. Can be provided up to "
"three times to get full debug logging")
verbosity_parser.add_argument("--verbosity", type=int,
help="Increase verbosity of logging. Supported values are 0 to 3"
)

parser.add_argument('-m', '--domain', help="XMPP server to connect to",
default='lobby.wildfiregames.com')
parser.add_argument('-l', '--login', help="username for login", default='xpartamupp')
Expand All @@ -392,12 +401,10 @@ def parse_args():
parser.add_argument('-r', '--room', help="XMPP MUC room to join", default='arena')
parser.add_argument('-s', '--server', help='address of the ejabberd server',
action='store', dest='xserver', default=None)
parser.add_argument('-v', action="count", dest='verbosity', default=0,
help="Increase verbosity of logging. Can be provided up to three times to "
"get full debug logging")
parser.add_argument('--no-verify',
help="Don't verify the TLS server certificate when connecting",
action='store_true')

return parser.parse_args()


Expand Down

0 comments on commit 1eb48c5

Please sign in to comment.