Skip to content

josh-proxy: use clap derive #1292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Nov 1, 2023

This simplifies the argument parsing a lot - we can almost parse the needed structure just with that, including all the manual default handling.

The only thing that does change is the handling of upstreams - rather than populating two fields in the Arg struct, it now contains a Vec<Remote>.

We can use clap to ensure there's at least one element (same for local), but comparison of individual args and further validation (max 2, not two of the same type) is now left to josh-proxy.rs.

For this, a make_upstream is introduced, turning that list of enums with URLs into a JoshProxyUpstream.

Error handling in run_proxy isn't awfully verbose, just exit nonzero, so I opted to log that specific error with an eprintln!, but happy to also add it for all errors (in main()).

This is in preparation for
#1288.

This simplifies the argument parsing a lot - we can almost parse the
needed structure just with that, including all the manual default
handling.

The only thing that does change is the handling of upstreams - rather
than populating two fields in the Arg struct, it now contains a
`Vec<Remote>`.

We can use clap to ensure there's at least one element (same for local),
but comparison of individual args and further validation (max 2, not two
of the same type) is now left to `josh-proxy.rs`.

For this, a `make_upstream` is introduced, turning that list of enums
with URLs into a JoshProxyUpstream.

Error handling in run_proxy isn't awfully verbose, just exit nonzero, so
I opted to log *that* specific error with an eprintln!, but happy to
also add it for all errors (in main()).

This is in preparation for
josh-project#1288.
@christian-schilling christian-schilling merged commit 465dd8f into josh-project:master Nov 1, 2023
@flokli flokli deleted the clap-derive branch November 2, 2023 05:30
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.

2 participants