]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
update python-template
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 24 Apr 2026 16:56:25 +0000 (18:56 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 24 Apr 2026 16:56:25 +0000 (18:56 +0200)
templates/default-py.py

index 9e89b762b6acddb9e32baa74d2d8bb8df365f2ae..ce416ec1a2e24b3d3d6fd36195205af70ac576e1 100755 (executable)
@@ -1,9 +1,16 @@
 #!/usr/bin/env python3
-"""Script to
+"""
+`( file-name-nondirectory  (buffer-file-name))`
+
+DESCRIPTION
+    $0
 
-Authors:
-   `( bba-insert-name )`
+AUTHOR
+    `(user-full-name)` <`user-mail-address`>
 
+LICENSE
+    This program is free software; you can redistribute it and/or modify
+    it under the same terms as Python itself.
 """
 
 import argparse
@@ -11,25 +18,47 @@ import logging
 import sys
 
 def main():
-    """Main function.
-    """
-    parser = argparse.ArgumentParser(description='Druid Rollups and Drops')
-    parser.add_argument('--config-file', dest='config_file',
-                        help='JSON config file', required=True)
-    parser.add_argument('--template-dir', dest='template_dir',
-                        help='Directory for druid templates', required=True)
-    parser.add_argument('--log-level', dest='log_level',
-                        help='Log level, can be one of: INFO, WARNING, ERROR, '
-                        'DEBUG', default='INFO')
+    parser = argparse.ArgumentParser(
+        description="`( file-name-nondirectory  (buffer-file-name))`",
+        formatter_class=argparse.ArgumentDefaultsHelpFormatter
+    )
+
+    parser.add_argument(
+        "-v", "--verbose",
+        action="store_true",
+        help="enable verbose mode"
+    )
+    parser.add_argument(
+        "-m", "--man",
+        action="store_true",
+        help="display full manual (same as --help with -v)"
+    )
+    # The original Perl script expected a `server` option
+    parser.add_argument(
+        "--server",
+        required=False,
+        help="server address (required unless --help is used)"
+    )
+
     args = parser.parse_args()
     logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                         level=args.log_level)
     logging.getLogger("requests").setLevel(logging.WARNING)
-    if len(args) != 1:
-        _error('No parameters')
+
+    if not args.server:
+        # mimic pod2usage(1)
         parser.print_usage()
         sys.exit(1)
- 
+
+    if args.man:
+        # mimic pod2usage(-verbose => 2)
+        print(__doc__)
+        sys.exit(0)
+
+    # ----- placeholder for real logic -----
+    if args.verbose:
+        print("Verbose mode ON")
+    print(f"Connecting to server: {args.server}")
 
 if __name__ == "__main__":
     main()