Skip to content

fix: deduplicate CLI option definitions to fix missing --email flag (#525)#527

Merged
buger merged 1 commit intomainfrom
fix/525-cli-help-missing-flags
Mar 11, 2026
Merged

fix: deduplicate CLI option definitions to fix missing --email flag (#525)#527
buger merged 1 commit intomainfrom
fix/525-cli-help-missing-flags

Conversation

@buger
Copy link
Copy Markdown
Contributor

@buger buger commented Mar 11, 2026

Summary

  • Root cause: CLI option definitions were duplicated across 3 methods (setupProgram(), parseArgs(), getHelpText()) with no shared source of truth. Each time a new flag was added, only setupProgram() was updated while the other two drifted.
  • Extract a single configureOptions() method that all three methods use, eliminating the entire class of "missing flag" bugs
  • Add email to the parseArgs() return value (was missing, forcing (options as any).email casts in cli-main.ts)
  • Remove as any casts in cli-main.ts for telegram, email, whatsapp, teams, a2a

Flags fixed

Flag Was missing from
--email parseArgs(), getHelpText()
--whatsapp parseArgs(), getHelpText()
--teams parseArgs(), getHelpText()
--slack getHelpText()
--telegram getHelpText()
--a2a getHelpText()
--no-remote-extends parseArgs(), getHelpText()
--allowed-remote-patterns setupProgram(), getHelpText()
--message getHelpText()
--watch getHelpText()
--task-tracking getHelpText()
--github-* (4 flags) getHelpText()

Test plan

  • New cli-options-consistency.test.ts validates all frontend flags appear in help and parse correctly
  • Structural test extracts all --options from help text and verifies each is accepted by parseArgs() — prevents future drift
  • All existing CLI tests pass (134 tests)
  • Build succeeds

Closes #525

🤖 Generated with Claude Code

…525)

The CLI had three separate copies of option definitions (setupProgram,
parseArgs, getHelpText) that drifted out of sync. Extract a single
configureOptions() method as the source of truth. This also fixes
--whatsapp, --teams, --no-remote-extends, --allowed-remote-patterns,
--message, --watch, --task-tracking, and --github-* flags missing from
help or parseArgs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@probelabs
Copy link
Copy Markdown
Contributor

probelabs bot commented Mar 11, 2026

PR Overview

Summary

This PR fixes issue #525 where the --email flag (and several other CLI flags) were missing from the help text and not properly parsed by parseArgs(). The root cause was code duplication: CLI option definitions were duplicated across three methods (setupProgram(), parseArgs(), getHelpText()) with no shared source of truth.

Root Cause Analysis

The CLI class in src/cli.ts had three separate methods that each defined their own copy of all CLI options:

  • setupProgram(): Configured the main this.program instance for actual CLI execution
  • parseArgs(): Created a temporary tempProgram instance for argument parsing
  • getHelpText(): Created another temporary tempProgram instance for help text generation

When new flags were added, developers typically only updated setupProgram(), causing the other two methods to drift out of sync. This resulted in:

  • Flags missing from --help output
  • Flags not being parsed correctly (returning undefined instead of boolean values)
  • The need for unsafe (options as any).email type casts in cli-main.ts

Solution

The PR extracts a single configureOptions() method that serves as the single source of truth for all CLI option definitions. All three methods now call this shared function.

Files Changed

1. src/cli.ts (main refactoring)

  • Added: configureOptions() method - single source of truth for option definitions
  • Modified: setupProgram() - now calls configureOptions(this.program)
  • Modified: parseArgs() - now calls configureOptions(tempProgram)
  • Modified: getHelpText() - now calls configureOptions(tempProgram)
  • Added: --allowed-remote-patterns option to configureOptions() (was missing from setupProgram())
  • Net change: -116 lines (eliminated ~144 lines of duplication)

2. src/cli-main.ts (type safety fixes)

  • Removed: 5 instances of (options as any) type casts for telegram, email, whatsapp, teams, a2a
  • Root cause: parseArgs() now properly returns these properties (added email: Boolean(options.email))
  • Net change: 0 lines (6 additions, 6 deletions)

3. tests/unit/cli-options-consistency.test.ts (new test file)

  • Added: 79 lines of structural tests to prevent future drift
  • Test 1: Verifies all frontend flags (--slack, --telegram, --email, --whatsapp, --teams, --a2a) appear in help text
  • Test 2: Verifies all frontend flags are accepted by parseArgs() without error
  • Test 3: Verifies parseArgs() returns the email property (regression test for CLI: --email flag missing from help output #525)
  • Test 4: Structural test that extracts ALL --option names from help text and verifies each is accepted by parseArgs() - prevents future drift

Flags Fixed by This Change

Flag Was Missing From
--email parseArgs(), getHelpText()
--whatsapp parseArgs(), getHelpText()
--teams parseArgs(), getHelpText()
--slack getHelpText()
--telegram getHelpText()
--a2a getHelpText()
--no-remote-extends parseArgs(), getHelpText()
--allowed-remote-patterns setupProgram(), getHelpText()
--message getHelpText()
--watch getHelpText()
--task-tracking getHelpText()
--github-* (4 flags) getHelpText()

Architecture & Impact

Before: Three separate option definitions with drift

setupProgram()  ── 30+ options (complete)
parseArgs()     ── 28+ options (missing email, whatsapp, teams, no-remote-extends)
getHelpText()   ── 20+ options (missing many frontend flags)

After: Single source of truth

configureOptions() ── All 30+ options (single source)
     ├─ setupProgram() calls configureOptions()
     ├─ parseArgs() calls configureOptions()
     └─ getHelpText() calls configureOptions()

Affected System Components

  • CLI parsing layer: src/cli.ts - CLI class
  • Main entry point: src/cli-main.ts - type casts removed
  • Test suite: tests/unit/cli-options-consistency.test.ts - new structural tests

Testing

  • New test file: cli-options-consistency.test.ts with 4 test cases
  • Structural test: Extracts all --option patterns from help text and verifies each is parseable
  • All existing tests pass: 134 tests
  • Build succeeds: No compilation errors

References

  • src/cli.ts:26-42 - New configureOptions() method
  • src/cli.ts:47-50 - Modified setupProgram() calling configureOptions()
  • src/cli.ts:154-158 - Modified parseArgs() calling configureOptions()
  • src/cli.ts:228-230 - Modified getHelpText() calling configureOptions()
  • src/cli-main.ts:1636-1641 - Removed (options as any) casts
  • src/cli-main.ts:2034 - Removed (options as any).email cast
  • tests/unit/cli-options-consistency.test.ts:1-79 - New consistency tests
Metadata
  • Review Effort: 2 / 5
  • Primary Label: bug

Powered by Visor from Probelabs

Last updated: 2026-03-11T16:09:39.017Z | Triggered by: pr_opened | Commit: 2bb8346

💡 TIP: You can chat with Visor using /visor ask <your question>

@buger buger merged commit 730e34e into main Mar 11, 2026
11 of 14 checks passed
@probelabs
Copy link
Copy Markdown
Contributor

probelabs bot commented Mar 11, 2026

✅ Security Check Passed

No security issues found – changes LGTM.

✅ Security Check Passed

No security issues found – changes LGTM.

\n\n

✅ Architecture Check Passed

No architecture issues found – changes LGTM.

✅ Performance Check Passed

No performance issues found – changes LGTM.


Powered by Visor from Probelabs

Last updated: 2026-03-11T16:08:00.561Z | Triggered by: pr_opened | Commit: 2bb8346

💡 TIP: You can chat with Visor using /visor ask <your question>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: --email flag missing from help output

1 participant