Skip to content
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

Replace Structopt with Clap v3 #216

Merged
merged 15 commits into from
Jan 29, 2022
Merged

Replace Structopt with Clap v3 #216

merged 15 commits into from
Jan 29, 2022

Conversation

ducaale
Copy link
Owner

@ducaale ducaale commented Dec 24, 2021

@ducaale ducaale marked this pull request as ready for review January 1, 2022 09:18
Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

I like how some of our custom logic is handled by clap now.

src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Show resolved Hide resolved
src/cli.rs Show resolved Hide resolved
generate.sh Outdated Show resolved Hide resolved
src/cli.rs Show resolved Hide resolved
@ducaale
Copy link
Owner Author

ducaale commented Jan 1, 2022

Hmm, it seems clap-rs/clap#3232 didn't completely fix clap-rs/clap#3215

$ cargo run -- --help
xh 0.14.1
-native-tls
xh is a friendly and fast tool for sending HTTP requests

USAGE:
    xh [OPTIONS] <[METHOD] URL> [--] [REQUEST_ITEM]...

ARGS:
    <[METHOD] URL>       The request URL, preceded by an optional HTTP method
    <REQUEST_ITEM>...    Optional key-value pairs to be included in the request

Edit: I managed to work around this issue by passing version to clap. See e7a0204.

@blyxxyz
Copy link
Collaborator

blyxxyz commented Jan 1, 2022

It's outside the scope of this PR, but custom help headings may be interesting.

@ducaale
Copy link
Owner Author

ducaale commented Jan 1, 2022

It's outside the scope of this PR, but custom help headings may be interesting.

Looks interesting.

xh 0.14.1
-native-tls
xh is a friendly and fast tool for sending HTTP requests

USAGE:
    xh [OPTIONS] <[METHOD] URL> [--] [REQUEST_ITEM]...

ARGS:
    <[METHOD] URL>       The request URL, preceded by an optional HTTP method
    <REQUEST_ITEM>...    Optional key-value pairs to be included in the request

OPTIONS:
        --native-tls      Use the system TLS library instead of rustls (if enabled at compile time)
        --https           Make HTTPS requests if not specified in the URL
    -I, --ignore-stdin    Do not attempt to read stdin
        --curl            Print a translation to a `curl` command
        --curl-long       Use the long versions of curl's flags
        --help            Print help information
    -V, --version         Print version information

Predefined Content Types:
    -j, --json         (default) Serialize data items from the command line as a JSON object
    -f, --form         Serialize data items from the command line as form fields
    -m, --multipart    Like --form, but force a multipart/form-data request even without files
        --raw <RAW>    Pass raw request data without extra processing

Output Processing:
        --pretty <STYLE>                 Controls output processing [possible values: all, colors, format, none]
    -s, --style <THEME>                  Output coloring style [possible values: auto, solarized, monokai, fruity]
        --response-charset <ENCODING>    Override the response encoding for terminal display purposes
        --response-mime <MIME_TYPE>      Override the response mime type for coloring and formatting for the terminal

Output Options:
    -p, --print <FORMAT>            String specifying what the output should contain
    -h, --headers                   Print only the response headers. Shortcut for --print=h
    -b, --body                      Print only the response body. Shortcut for --print=b
    -v, --verbose                   Print the whole request as well as the response
        --all                       Show any intermediary requests/responses while following redirects with --follow
    -P, --history-print <FORMAT>    The same as --print but applies only to intermediary requests/responses
    -q, --quiet                     Do not print to stdout or stderr
    -S, --stream                    Always stream the response body
    -o, --output <FILE>             Save output to FILE instead of stdout
    -d, --download                  Download the body to a file instead of printing it
    -c, --continue                  Resume an interrupted download. Requires --download and --output

Sessions:
        --session <FILE>              Create, or reuse and update a session
        --session-read-only <FILE>    Create or read a session without updating it form the request/response exchange

Authentication:
    -A, --auth-type <AUTH_TYPE>         Specify the auth mechanism [possible values: basic, bearer, digest]
    -a, --auth <USER[:PASS] | TOKEN>    Authenticate as USER with PASS or with TOKEN
        --ignore-netrc                  Do not use credentials from .netrc

Network:
        --offline                   Construct HTTP requests without sending them anywhere
        --check-status              (default) Exit with an error status code if the server replies with an error
    -F, --follow                    Do follow redirects
        --max-redirects <NUM>       Number of redirects to follow, only respected if `follow` is set
        --timeout <SEC>             Connection timeout of the request
        --proxy <PROTOCOL:URL>      Use a proxy for a protocol. For example: `--proxy https:http://proxy.host:8080`
        --http-version <VERSION>    HTTP version to use [possible values: 1.0, 1.1, 2]

SSL:
        --verify <VERIFY>    If "no", skip SSL verification. If a file path, use it as a CA bundle
        --cert <FILE>        Use a client side certificate for SSL
        --cert-key <FILE>    A private key file to use with --cert
        --ssl <VERSION>      Force a particular TLS version [possible values: auto, tls1, tls1.1, tls1.2, tls1.3]

Each option can be reset with a --no-OPTION argument.


Run `xh help` for more complete documentation.

But I agree it is better to explore the help headings feature in another PR.

Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

Looks good!

generate.sh Outdated Show resolved Hide resolved
src/request_items.rs Outdated Show resolved Hide resolved
ducaale and others added 2 commits January 29, 2022 23:11
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
@ducaale ducaale merged commit f22d73b into develop Jan 29, 2022
@ducaale ducaale deleted the clap3 branch January 29, 2022 23:15
@ducaale ducaale linked an issue Mar 8, 2022 that may be closed by this pull request
4 tasks
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.

Fixes for clap v3
2 participants