-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cargo-apk: Reimplement "default" (
--
) subcommand trailing args for …
…`cargo` (#363) * 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) * 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. * 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`.
- Loading branch information
Showing
2 changed files
with
223 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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