From fae244f02f414fdb627679bef6f6f4773621101e Mon Sep 17 00:00:00 2001 From: Brad Date: Sun, 26 Apr 2026 10:39:47 -0400 Subject: [PATCH] Fix Python 3.6 argparse compatibility --- README.md | 7 ++++--- ndrift | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 95a7a6b..4595f7b 100644 --- a/README.md +++ b/README.md @@ -127,9 +127,10 @@ If scan_updates_baseline is true, ndrift updates baseline after each scan. ### Requirements 1. Linux -2. Python 3 -3. optional: lsattr for filesystem attribute checks -4. optional: AWS CLI for object storage report upload +2. Python 3.6 or newer +3. for Python 3.6 only: dataclasses backport package +4. optional: lsattr for filesystem attribute checks +5. optional: AWS CLI for object storage report upload ### Local install in project directory diff --git a/ndrift b/ndrift index 3090bef..b12a615 100755 --- a/ndrift +++ b/ndrift @@ -1268,7 +1268,8 @@ def build_parser() -> argparse.ArgumentParser: prog="ndrift", description="Lightweight file integrity monitor for Linux", ) - sub = parser.add_subparsers(dest="command", required=True) + sub = parser.add_subparsers(dest="command") + sub.required = True init_cmd = sub.add_parser("init", help="create baseline") init_cmd.add_argument("directories", nargs="+", help="directories to monitor") @@ -1338,6 +1339,9 @@ def main(argv: Optional[List[str]] = None) -> int: """Main entry point for CLI execution.""" parser = build_parser() args = parser.parse_args(argv) + if getattr(args, "command", None) is None: + parser.print_help(sys.stderr) + return EXIT_ERROR try: return dispatch(args) except NdriftError as exc: