Skip to content

Improve CLI help text: I/O contract, dynamic commands, config precedence#1555

Merged
garrytrinder merged 6 commits intomainfrom
copilot/improve-help-text
Feb 26, 2026
Merged

Improve CLI help text: I/O contract, dynamic commands, config precedence#1555
garrytrinder merged 6 commits intomainfrom
copilot/improve-help-text

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

--help output lacks information agents and users need to understand output routing, command variability, and config resolution. This is only discoverable by reading source code.

Changes

  • --config-file description: Updated to document default lookup (devproxyrc.json in cwd) and ~appFolder token support
  • Custom help sections (root command only, via DevProxyHelpAction wrapping HelpAction):
    • Dynamic plugin commands note after the commands list
    • I/O contract: stdout vs stderr routing
    • Configuration precedence: CLI flags > config file > defaults
  • Startup noise: Already suppressed via HasGlobalOptions filter on DevProxy.Plugins.* — no changes needed

Root --help now ends with:

  Additional commands may be available depending on configured plugins.
  Use -c <config-file> to load a specific configuration.

Output:
  Primary output goes to stdout. Errors and diagnostics go to stderr.
  Use --log-for Machine for structured output.

Configuration precedence:
  CLI flags > config file > defaults

Subcommand help is unaffected — the extra sections are gated on parseResult.CommandResult.Command is RootCommand.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --help (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy --version (dns block)
    • Triggering command: /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy /home/REDACTED/work/dev-proxy/dev-proxy/DevProxy/bin/Debug/net10.0/devproxy cert --help (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve help text: I/O contract, dynamic commands, config precedence, startup noise</issue_title>
<issue_description>Parent: #1534

Problem

Several aspects of the CLI behavior are undocumented in --help and only discoverable by reading source code or running experiments:

1. No I/O contract

Help text doesn't state where output goes (stdout vs stderr). The actual routing is:

  • LogLevel.Information and below → stdout
  • LogLevel.Warning and above → stderr
  • Validation errors → stdout (mixed with help text)
  • jwt create token → stdout (via Console.WriteLine)

An agent capturing stdout to get the JWT token might also capture log noise.

2. Dynamic plugin commands are invisible

Available commands change based on which config file is loaded (plugins can contribute commands via GetCommands()). An agent reading --help with one config sees different commands than with another. There's no indication this is happening.

3. Config file precedence undocumented

Dev Proxy silently looks for devproxyrc.json in the current directory. Paths can use ~appFolder token. The option precedence is: CLI flag > config file > hardcoded default. None of this is in --help.

4. Startup log noise on --help and --version

Running devproxy --help outputs plugin initialization logs before the help text:

 info    1 error responses loaded from .../devproxy-errors.json

This pollutes otherwise clean informational output.

Rationale

Agents build mental models from --help. Implicit behaviors that affect output content, command availability, or configuration resolution must be documented — agents have no other way to discover them.

Proposed solution

I/O contract — add to root --help:

Output:
  Primary output goes to stdout. Errors and diagnostics go to stderr.
  Use --output json for structured output.

Dynamic commands — add note to commands section:

Commands:
  cert             Manage the Dev Proxy certificate
  config           Manage Dev Proxy configs
  ...

  Additional commands may be available depending on configured plugins.
  Use -c <config-file> to load a specific configuration.

Config file — update --config-file description:

-c, --config-file <config-file>  Path to config file. Defaults to devproxyrc.json
                                  in current directory. Supports ~appFolder token.

Config precedence — add to root --help:

Configuration precedence:
  CLI flags > config file > defaults

Suppress startup noise

When --help or --version is invoked, suppress all plugin initialization and log output. These are pure informational commands with no side effects — they should produce clean output only.

Affected code

  • DevProxy/Commands/DevProxyCommand.cs — help text additions
  • DevProxy/Program.cs — suppress initialization on help/version
  • DevProxy/Extensions/IServiceCollectionExtensions.cs — potentially skip plugin loading for help/version
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve help text for I/O contract and commands Improve CLI help text: I/O contract, dynamic commands, config precedence Feb 25, 2026
@waldekmastykarz waldekmastykarz marked this pull request as ready for review February 25, 2026 13:17
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner February 25, 2026 13:17
Copilot AI review requested due to automatic review settings February 25, 2026 13:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Dev Proxy’s root CLI --help output so users (and agents) can understand configuration resolution, dynamic plugin commands, and stdout/stderr routing without reading source.

Changes:

  • Adds a custom root-only help tail section (dynamic plugin commands note, output routing, config precedence) by wrapping HelpAction with DevProxyHelpAction.
  • Updates --config-file option description to document default lookup behavior and ~appFolder token support.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
DevProxy/Commands/DevProxyHelpAction.cs Adds a HelpAction wrapper that appends extra root-only help sections.
DevProxy/Commands/DevProxyCommand.cs Hooks help customization into root command setup and updates --config-file help text.

Copy link
Contributor

@garrytrinder garrytrinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested: builds clean. Root help now shows I/O contract, dynamic commands note, config precedence, exit codes. Config-file description updated. DevProxyHelpAction fixed to chain with HelpExamples (accepts SynchronousCommandLineAction). --log-for reference updated to --output json. Subcommand help correctly excludes root-only sections. LGTM.

@garrytrinder garrytrinder enabled auto-merge (squash) February 26, 2026 12:34
@garrytrinder garrytrinder merged commit 7bb8491 into main Feb 26, 2026
4 checks passed
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.

Improve help text: I/O contract, dynamic commands, config precedence, startup noise

4 participants