"build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" |
"git-checkout" | "init" | "install" | "locate-project" | "login" | "metadata" |
"new" | "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" |
- "rustc" | "rustdoc" => true,
+ "rustc" | "rustdoc" | "search" => true,
_ => false
});
// $mac!(run);
// $mac!(rustc);
// $mac!(rustdoc);
- $mac!(search);
+// $mac!(search);
$mac!(test);
$mac!(uninstall);
$mac!(update);
use std::slice;
use std::io::{self, BufRead};
use std::path::PathBuf;
+use std::cmp::min;
use clap::{AppSettings, Arg, ArgMatches};
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
-wants the location of the index to which to publish. Please
-use '--index' instead.
+wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
required_features_filterable: false,
};
};
- match ops::run(&ws, &compile_opts, &values(args, "args"))? {
+ return match ops::run(&ws, &compile_opts, &values(args, "args"))? {
None => Ok(()),
Some(err) => {
// If we never actually spawned the process then that sounds pretty
CliError::new(err.into(), exit_code)
})
}
- }
+ };
}
("rustc", Some(args)) => {
let ws = workspace_from_args(config, args)?;
ops::doc(&ws, &doc_opts)?;
return Ok(());
}
+ ("search", Some(args)) => {
+ let registry = registry_from_args(config, args)?;
+ let index = index_from_args(config, args)?;
+ let limit: Option<u8> = args.value_of("limit")
+ .and_then(|v| v.parse().ok()); //FIXME: validation
+ let limit = min(100, limit.unwrap_or(10));
+ let query: Vec<&str> = args.values_of("query").unwrap_or_default().collect();
+ let query: String = query.join("+");
+ ops::search(&query, config, index, limit, registry)?;
+ return Ok(());
+ }
_ => return Ok(())
}
}
run::cli(),
rustc::cli(),
rustdoc::cli(),
+ search::cli(),
])
;
app
mod run;
mod rustc;
mod rustdoc;
+mod search;
mod utils {
use clap::{self, SubCommand, AppSettings};
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("search")
+ .about("Search packages in crates.io")
+ .arg(Arg::with_name("query").multiple(true))
+ .arg_index()
+ .arg(
+ opt("limit", "Limit the number of results (default: 10, max: 100)")
+ .value_name("LIMIT")
+ )
+ .arg(opt("registry", "Registry to use").value_name("REGISTRY"))
+}
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
-wants the location of the index to which to publish. Please
-use '--index' instead.
+wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
-wants the location of the index to which to publish. Please
-use '--index' instead.
+wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
-wants the location of the index in which to search. Please
-use '--index' instead.
+wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
-wants the location of the index in which to search. Please
-use '--index' instead.
+wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer