@@ -5,7 +5,8 @@ use std::cmp;
5
5
6
6
#[ derive( Deserialize ) ]
7
7
pub struct Options {
8
- flag_host : Option < String > ,
8
+ flag_index : Option < String > ,
9
+ flag_host : Option < String > , // TODO: Depricated, remove
9
10
flag_verbose : u32 ,
10
11
flag_quiet : Option < bool > ,
11
12
flag_color : Option < String > ,
24
25
25
26
Options:
26
27
-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'
28
30
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
29
31
-q, --quiet No output printed to stdout
30
32
--color WHEN Coloring: auto, always, never
@@ -40,12 +42,37 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
40
42
options. flag_frozen ,
41
43
options. flag_locked ) ?;
42
44
let Options {
43
- flag_host : host,
45
+ flag_index : index,
46
+ flag_host : host, // TODO: Depricated, remove
44
47
flag_limit : limit,
45
48
arg_query : query,
46
49
..
47
50
} = options;
48
51
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 ) ?;
50
77
Ok ( ( ) )
51
78
}
0 commit comments