Repository navigation
Gateway - Replace custom cli parsing code with clap - #161
Merged
Merged
Conversation
awheeler294
force-pushed
the
clap-for-gateway
branch
from
October 21, 2026 16:51
dde7aac to
8b46230
Compare
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
force-pushed
the
clap-for-gateway
branch
from
October 21, 2026 18:56
8b46230 to
31941a4
Compare
|
Closes #152. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Mainconstructs anAppOptionsby callingfrom_args(),from_args()parses the args using theClistruct, andmainusesAppOptionsto decide how to run.Clistruct to define and parse the command line interfaceInvocationtoAppOptionsto better reflect what it does. Movedparse_argstoAppOptions::from_argsfor a one-stop constructor