|
15 | 15 | use self::super::ops::{PackageFilterElement, ConfigOperation};
|
16 | 16 | use semver::{VersionReq as SemverReq, Version as Semver};
|
17 | 17 | use clap::{self, AppSettings, SubCommand, App, Arg};
|
| 18 | +use std::ffi::{OsString, OsStr}; |
18 | 19 | use array_tool::vec::Uniq;
|
19 | 20 | use std::path::PathBuf;
|
20 | 21 | use std::str::FromStr;
|
21 | 22 | use dirs::home_dir;
|
22 |
| -use std::env; |
23 |
| -use std::fs; |
| 23 | +use std::{env, fs}; |
24 | 24 |
|
25 | 25 |
|
26 | 26 | /// Representation of the application's all configurable values.
|
@@ -49,6 +49,8 @@ pub struct Options {
|
49 | 49 | pub cargo_dir: (String, PathBuf),
|
50 | 50 | /// The temporary directory to clone git repositories to. Default: `"$TEMP/cargo-update"`
|
51 | 51 | pub temp_dir: (String, PathBuf),
|
| 52 | + /// Arbitrary arguments to forward to `cargo install`, acquired from `$CARGO_INSTALL_OPTS`. Default: `[]` |
| 53 | + pub cargo_install_args: Vec<OsString>, |
52 | 54 | }
|
53 | 55 |
|
54 | 56 | /// Representation of the config application's all configurable values.
|
@@ -86,6 +88,13 @@ impl Options {
|
86 | 88 | Arg::from_usage("-q --quiet 'No output printed to stdout'"),
|
87 | 89 | Arg::from_usage("-s --filter=[PACKAGE_FILTER]... 'Specify a filter a package must match to be considered'")
|
88 | 90 | .validator(|s| PackageFilterElement::parse(&s).map(|_| ())),
|
| 91 | + Arg::with_name("cargo_install_opts") |
| 92 | + .long("__cargo_install_opts") |
| 93 | + .env("CARGO_INSTALL_OPTS") |
| 94 | + .empty_values(false) |
| 95 | + .multiple(true) |
| 96 | + .value_delimiter(" ") |
| 97 | + .hidden(true), |
89 | 98 | Arg::from_usage("[PACKAGE]... 'Packages to update'")
|
90 | 99 | .empty_values(false)
|
91 | 100 | .min_values(1)
|
@@ -145,6 +154,7 @@ impl Options {
|
145 | 154 | }),
|
146 | 155 | temp_pb.join("cargo-update"))
|
147 | 156 | },
|
| 157 | + cargo_install_args: matches.values_of_os("cargo_install_opts").into_iter().flat_map(|cio| cio.map(OsStr::to_os_string)).collect(), |
148 | 158 | }
|
149 | 159 | }
|
150 | 160 | }
|
|
0 commit comments