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

cargo-apk: Reimplement "default" (--) subcommand trailing args for cargo #363

Merged
merged 3 commits into from
Nov 23, 2022

Commits on Nov 23, 2022

  1. cargo-apk: Reimplement "default" subcommand trailing args for cargo

    … with `--` separator
    
    `clap` [does not currently support] parsing unknown arguments into a
    side `Vec`, which is exactly what `cargo apk --` needs to parse a few
    known `cargo` arguments (such as `--target` and `-p`) but forward the
    rest verbatim to the underlying `cargo` subcommand.
    
    `allow_hyphen_values = true` could partially help us out with this, but
    it parses all remaining arguments into that `Vec` upon encountering the
    first unknown flag/arg, resulting in all known flags after that to also
    be treated as "unknown" instead of filling up our `args: Args` struct.
    
    Since [a workaround for this isn't currently functioning], introduce
    pure trailing args with an additional `--` separator to make it clear
    which arguments go to `cargo-apk` (and are almost all, except
    `--device`, forwarded to `cargo`) and which are only passed to `cargo
    <subcommand>`.
    
    [does not currently support]: clap-rs/clap#1404
    [a workaround for this isn't currently functioning]: clap-rs/clap#1404 (comment)
    MarijnS95 committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    7b1c777 View commit details
    Browse the repository at this point in the history
  2. cargo-apk: Separate unrecognized cargo arguments from cargo-apk Args

    With some custom logic, and assuming (validated with an `assert!`) our
    `Args` struct doesn't have any positionals, we can implement argument
    separation ourselves: this allows the user to mix and match `cargo
    <subcommand>` arguments with arguments recognized by `cargo-apk`, and
    expect `cargo-apk` to set up the environment as expected (as it did
    previously) by taking these arguments into account while disregarding
    _only_ unknown arguments.
    MarijnS95 committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    bbda575 View commit details
    Browse the repository at this point in the history
  3. Add args: Args back to Ndk subcommand to see them in -h

    Mixed `cargo-apk` and `cargo` args will still be split out from
    `cargo_args`, and they'll be appended to existing values for `args`.
    MarijnS95 committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    e2b9db4 View commit details
    Browse the repository at this point in the history