Support patterns in pkg list
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3116,6 +3116,7 @@ dependencies = [
|
||||
"embedded-triple 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hlua-badtouch 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipnetwork 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
||||
@@ -75,6 +75,7 @@ hmac = "0.7"
|
||||
|
||||
walkdir = "2.2"
|
||||
nude = "0.3"
|
||||
glob = "0.3.0"
|
||||
|
||||
[target.'cfg(target_os="linux")'.dependencies]
|
||||
caps = "0.3"
|
||||
|
||||
@@ -71,6 +71,9 @@ pub struct List {
|
||||
/// List outdated modules
|
||||
#[structopt(long="outdated")]
|
||||
pub outdated: bool,
|
||||
/// Filter by pattern
|
||||
#[structopt(default_value="*")]
|
||||
pub pattern: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
@@ -97,6 +100,8 @@ fn run_subcommand(subcommand: SubCommand, library: &Library, config: &Config) ->
|
||||
SubCommand::List(list) => {
|
||||
let autoupdate = AutoUpdater::load()?;
|
||||
|
||||
let filter = glob::Pattern::new(&list.pattern)?;
|
||||
|
||||
for module in library.list() {
|
||||
if let Some(source) = &list.source {
|
||||
if !module.source_equals(&source) {
|
||||
@@ -105,6 +110,9 @@ fn run_subcommand(subcommand: SubCommand, library: &Library, config: &Config) ->
|
||||
}
|
||||
|
||||
let canonical = module.canonical();
|
||||
if !filter.matches(&canonical) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut out = String::new();
|
||||
write!(&mut out, "{} ({})", canonical.green(),
|
||||
|
||||
Reference in New Issue
Block a user