From 8a9c7828126ab23e6a019096739745a465c52c51 Mon Sep 17 00:00:00 2001 From: hiyouwhatsapp <89997383+hiyouwhatsapp@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:56:20 +0300 Subject: [PATCH] fix(cli): preserve root flags before subcommands Suppress omitted subparser defaults so explicit safety flags and paths survive parsing. Cover both flag positions, omitted defaults and subcommand precedence. Fixes #414 Resolves: CR-A05-001 --- CHANGELOG.md | 1 + forgelm/cli/_parser.py | 15 +++++++---- tests/test_cli.py | 55 ++++++++++++++++++++++++++++++++++++++ tools/check_module_size.py | 7 ++++- 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 904500f6..976c967b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ All notable changes to ForgeLM are documented here. ### Fixed +- Preserve top-level `--dry-run`, `--config`, `--offline` and `--output` values when a subcommand omits the same flag (CR-A05-001, #414). - Fix the KTO bullet on the Alignment overview user-manual page (English and Turkish): it named the fields `(prompt, response, good?)`, but the KTO loader reads `prompt`, `completion` and a boolean `label` (#965). diff --git a/forgelm/cli/_parser.py b/forgelm/cli/_parser.py index 562c6343..be1c79ab 100644 --- a/forgelm/cli/_parser.py +++ b/forgelm/cli/_parser.py @@ -118,7 +118,9 @@ def _add_deploy_subcommand(subparsers) -> None: choices=["ollama", "vllm", "tgi", "hf-endpoints"], help="Target serving runtime.", ) - p.add_argument("--output", type=str, default=None, metavar="FILE", help="Output file path (default: auto).") + p.add_argument( + "--output", type=str, default=argparse.SUPPRESS, metavar="FILE", help="Output file path (default: auto)." + ) p.add_argument("--system", type=str, default=None, metavar="PROMPT", help="System prompt (Ollama only).") p.add_argument("--max-length", type=_positive_int, default=4096, help="Context window length (default: 4096).") p.add_argument( @@ -174,13 +176,14 @@ def _add_quickstart_subcommand(subparsers) -> None: p.add_argument( "--output", type=str, - default=None, + default=argparse.SUPPRESS, metavar="FILE", help="Where to write the generated YAML (default: ./configs/