From 1c183fb6b4d2f9299ea00330e93f5e6ef1943f70 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 26 Nov 2022 19:34:37 -0500 Subject: [PATCH] Group arg definitions more cleanly --- check_home_assistant_state.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/check_home_assistant_state.py b/check_home_assistant_state.py index 47d50ab..6a45dbe 100755 --- a/check_home_assistant_state.py +++ b/check_home_assistant_state.py @@ -56,6 +56,14 @@ class Entities(nagiosplugin.Resource): @nagiosplugin.guarded def main(): argp = argparse.ArgumentParser(description=__doc__) + argp.add_argument( + "-t", "--token", required=True, type=str, help="API token for Home Assistant" + ) + argp.add_argument( + "-u", "--url", required=True, type=str, help="URL for Home Assistant" + ) + argp.add_argument("-v", "--verbose", action="count", default=0) + argp.add_argument( "-w", "--warning", @@ -70,13 +78,7 @@ def main(): required=True, help="return critical if battery percentage is outside RANGE", ) - argp.add_argument( - "-t", "--token", required=True, type=str, help="API token for Home Assistant" - ) - argp.add_argument( - "-u", "--url", required=True, type=str, help="URL for Home Assistant" - ) - argp.add_argument("-v", "--verbose", action="count", default=0) + args = argp.parse_args() check = nagiosplugin.Check(