Skip to content

Gateway - Replace custom cli parsing code with clap - #161

Merged
awheeler294 merged 1 commit into
masterfrom
clap-for-gateway
Oct 21, 2026
Merged

awheeler294 merged 1 commit into
masterfrom
clap-for-gateway

Conversation

@awheeler294

@awheeler294 awheeler294 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Replace custom CLI parsing code in gateway with Clap. Clap is a de facto standard for command line parsing in Rust and gives us simpler, smaller, and more standard CLI code. It should also make it considerably easier to change the CLI in the future (add args, more subcommands, etc).

The workflow is basically the same as before: Main constructs an AppOptions by calling from_args(), from_args() parses the args using the Cli struct, and main uses AppOptions to decide how to run.

  • Add a Cli struct to define and parse the command line interface
  • Rename Invocation to AppOptions to better reflect what it does. Moved parse_args to AppOptions::from_args for a one-stop constructor
  • Add / update tests

@awheeler294 awheeler294 self-assigned this Oct 20, 2026
@awheeler294 awheeler294 added the Gateway A separate product used by PromptForge label Oct 20, 2026

@seanpar203 seanpar203 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Replace custom CLI parsing code in gateway with Clap. Clap is a de facto standard for command line parsing in Rust and gives us simpler, smaller, and more standard CLI code. It should also make it considerably easier to change the CLI in the future (add args, more subcommands, etc).

Code Changes:

The workflow is basically the same as before: Main constructs an AppOptions by calling from_args(), from_args() parses the args using the Cli struct, and main uses AppOptions to decide how to run.

- Add a Cli struct to define and parse the command line interface
- Rename Invocation to AppOptions to better reflect what it does. Moved parse_args to AppOptions::from_args for a one-stop constructor
- Add / update tests

User Facing Changes:

`runvil-gateway --help` now lists every option with a one-line
description, and states the order in which the gateway finds its config:
--config, then RUNVIL_GATEWAY_CONFIG, then the executable's directory,
the current directory, and the home directory's .runvil folder
(%USERPROFILE%\.runvil on Windows), where a default config is generated
when none is found. `runvil-gateway diagnostics --help` shows the
subcommand's own help. Help is colored on a terminal and plain when
piped.

A usage error prints the error, a short usage line, and a pointer to
`--help` instead of the whole usage text, for example "the subcommand
'diagnostics' cannot be used with '--no-tray'" or "invalid value '../x'
for '--profile <NAME>': profile name must not contain path separators".
Usage errors still exit with status 1.

Two behaviors change:
- Any flag given twice is an error. Before, only a repeated --config was
  rejected, and a second --profile silently replaced the first.
- -V works as a short form of --version.

The flags and the rules between them are otherwise unchanged:
`diagnostics` must come first and accepts only `--config`, `serve` and
positional arguments are rejected, `--supervised` stays hidden and
conflicts with `--print-url`, and `--login` still suppresses
`--browser`.
@awheeler294
awheeler294 merged commit 31941a4 into master Oct 21, 2026
19 checks passed
@drauschenbach

Copy link
Copy Markdown

Closes #152.

This branch was successfully deployed

1 active deployment
github-pages — 31941a46 Deployed Oct 21, 2026 by awheeler294 via deploy #130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gateway A separate product used by PromptForge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants