From 7a816e4292c02782f035cde57e6afd879681a7a2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 7 Jul 2021 14:14:35 +0200 Subject: [PATCH] i3-companion: enhance help with list of functions --- bin/i3-companion | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index e444510..2378b79 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -1,10 +1,6 @@ #!/usr/bin/python3 -"""Personal i3 companion - -This script will listen to i3 events and react accordingly. - -""" +"""Personal i3 companion.""" import argparse import logging @@ -24,11 +20,6 @@ from i3ipc import Event logger = logging.getLogger(os.path.splitext(os.path.basename(sys.argv[0]))[0]) -class CustomFormatter(argparse.RawDescriptionHelpFormatter, - argparse.ArgumentDefaultsHelpFormatter): - pass - - def on(*events): """Tag events that should be provided to the function.""" def decorator(fn): @@ -256,8 +247,10 @@ async def main(options): if __name__ == "__main__": # Parse - parser = argparse.ArgumentParser( - description=sys.modules[__name__].__doc__) + description = sys.modules[__name__].__doc__ + for fn, events in on.functions.items(): + description += f" {fn.__doc__}" + parser = argparse.ArgumentParser(description=description) parser.add_argument("--debug", "-d", action="store_true", default=False, help="enable debugging")