Skip to content

Commit 624b6f2

Browse files
committed
rename '--host' to '--index', add comments marked as TODO where host should be removed/repurposed
1 parent cc8aa6f commit 624b6f2

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/bin/search.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use std::cmp;
55

66
#[derive(Deserialize)]
77
pub struct Options {
8-
flag_host: Option<String>,
8+
flag_index: Option<String>,
9+
flag_host: Option<String>, // TODO: Depricated, remove
910
flag_verbose: u32,
1011
flag_quiet: Option<bool>,
1112
flag_color: Option<String>,
@@ -24,7 +25,8 @@ Usage:
2425
2526
Options:
2627
-h, --help Print this message
27-
--host HOST Host of a registry to search in
28+
--index INDEX Registry index to search in
29+
--host HOST DEPRICATED, renamed to '--index'
2830
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
2931
-q, --quiet No output printed to stdout
3032
--color WHEN Coloring: auto, always, never
@@ -40,12 +42,37 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
4042
options.flag_frozen,
4143
options.flag_locked)?;
4244
let Options {
43-
flag_host: host,
45+
flag_index: index,
46+
flag_host: host, // TODO: Depricated, remove
4447
flag_limit: limit,
4548
arg_query: query,
4649
..
4750
} = options;
4851

49-
ops::search(&query.join("+"), config, host, cmp::min(100, limit.unwrap_or(10)) as u8)?;
52+
// TODO: Depricated
53+
// remove once it has been decided --host can be safely removed
54+
// We may instead want to repurpose the host flag, as
55+
// mentioned in this issue
56+
// https://github.com/rust-lang/cargo/issues/4208
57+
58+
let msg = "The flag '--host' is no longer valid.
59+
60+
Previous versions of Cargo accepted this flag, but it is being
61+
depricated. The flag is being renamed to 'index', as the flag
62+
wants the location of the index in which to search. Please
63+
use '--index' instead.
64+
65+
This will soon become a hard error, so it's either recommended
66+
to update to a fixed version or contact the upstream maintainer
67+
about this warning.";
68+
69+
let index = if host.clone().is_none() || host.clone().unwrap().is_empty() {
70+
index
71+
} else {
72+
config.shell().warn(&msg)?;
73+
host
74+
};
75+
76+
ops::search(&query.join("+"), config, index, cmp::min(100, limit.unwrap_or(10)) as u8)?;
5077
Ok(())
5178
}

0 commit comments

Comments
 (0)