fix(cli): resolve option inheritance bug in launch help options#2396
fix(cli): resolve option inheritance bug in launch help options#2396abn wants to merge 2 commits into
Conversation
Replace index-based option hiding with a version-agnostic name filter that hides all options on the launch subcommand except help flags. This prevents CLI11 version discrepancies (2.4.2 vs 2.6.2) from causing option index shifts that corrupted option groups and help outputs.
|
Please add before-and-after screenshots to the PR description so that we can understand what the PR does. |
|
@jeremyfowers done 😄 |
|
The issue is triggered by a CLI11 version discrepancy.
To reproduce the bug on 1. Force CLI11 v2.6.2 in
|
Ah ok, I can reproduce the bug now, thanks for the script. |
There was a problem hiding this comment.
Thanks for the fix!
Fix tested with:
docker run --rm -i --entrypoint bash docker.io/ubuntu:22.04 <<'EOF'
set -xe
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
cmake \
ninja-build \
g++ \
libcurl4-openssl-dev \
libssl-dev \
zlib1g-dev \
libcap-dev \
pkg-config
git clone https://github.com/abn/lemonade.git /workspace
cd /workspace
git checkout fix/launch-help-options
# Force FetchContent to pull CLI11 v2.6.2 (disabling system autodetection)
sed -i 's/find_path(CLI11_INCLUDE_DIRS "CLI\/CLI.hpp")/set(CLI11_INCLUDE_DIRS "")/' CMakeLists.txt
sed -i 's/GIT_TAG v${MIN_CLI11_VERSION}/GIT_TAG v2.6.2/' CMakeLists.txt
# Configure and compile only the CLI client targe
cmake -B build -GNinja -DBUILD_WEB_APP=OFF .
cmake --build build --target lemonade
# 5. Run the help command to demonstrate the option leakage bug
./build/lemonade launch --help
EOF

Replace index-based option hiding with a version-agnostic name filter that hides all options on the launch subcommand except help flags. This prevents CLI11 version discrepancies (2.4.2 vs 2.6.2) from causing option index shifts that corrupted option groups and help outputs.
Motivation for me was because cli tests were failing when I was using system libs, so every time the tests would fail on local.
Below are the before-and-after snapshots of the CLI help output behavior.
🛑 Before (Index-shifting / Option Leakage Bug)
Due to option index shifting under different CLI11 versions, options defined on the
launchsubcommand (like--model,--directory, etc.) leaked into the root help output. This bloated the root command output and caused CI/CD consistency test assertions to fail:✅ After (Version-Agnostic Name Filtering Fix)
With the new version-agnostic name filtering, all option leakage on the parent subcommand is completely avoided.
1. Root
launchHelp Output (Options properly hidden)2. Agent Subcommand Help Output (Options correctly preserved on subcommands)
When checking help for a specific agent subcommand, the options are fully visible and accessible: