From 5944b0a7a4e91360c76e836ff9b36533defe16e6 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 26 May 2026 15:09:54 +0200 Subject: [PATCH] collect: add diff to credentials file; --diff overrides it Change --diff from store_true to default=None so CLI presence is distinguishable from the JSON default. If not given on CLI, reads creds_data.get("diff", False). Updated install.sh template and README. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 3 ++- collect.py | 5 ++++- install.sh | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64277de..7023bbc 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ All connection and collection settings live in a single JSON file: | `host` | `"0.0.0.0"` | Push server bind address | | `port` | `9999` | Push server TCP port | | `log_dir` | `"./logs"` | Directory for rotating JSON log files | +| `diff` | `false` | Enable diff mode for push server transmission | ### CLI reference @@ -97,7 +98,7 @@ CLI flags override the corresponding credentials file value when given. | `--port PORT` | `port` | Push server TCP port | | `--log-dir DIR` | `log_dir` | Directory for rotating log files | | `--max-records N` | — | Keep only the last N records per file | -| `--diff` | — | Send diffs instead of full snapshots (must match client setting) | +| `--diff` | `diff` | Send diffs instead of full snapshots (must match client setting) | | `--dry` | — | Skip WeConnect; run push server only (for testing) | | `-v` | — | Verbose / debug logging | | `--list-domains` | — | Print available domains and exit | diff --git a/collect.py b/collect.py index 8e28d75..effb68d 100644 --- a/collect.py +++ b/collect.py @@ -220,7 +220,8 @@ def main() -> None: p.add_argument( "--diff", action="store_true", - help="Send diffs instead of full snapshots over the push server (default: off)", + default=None, + help="Send diffs instead of full snapshots over the push server (overrides credentials file, default: off)", ) p.add_argument( "--dry", @@ -273,6 +274,8 @@ def main() -> None: args.port = int(creds_data.get("port", 9999)) if args.log_dir is None: args.log_dir = creds_data.get("log_dir", "./logs") + if args.diff is None: + args.diff = bool(creds_data.get("diff", False)) if not args.dry and (not args.username or not args.password): p.error( diff --git a/install.sh b/install.sh index 4e177c7..9652ca9 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,8 @@ if [[ ! -f "$CREDS_FILE" ]]; then "interval_s": 300, "host": "0.0.0.0", "port": 9999, - "log_dir": "./logs" + "log_dir": "./logs", + "diff": false } EOF chmod 600 "$CREDS_FILE"