Support patterns in pkg list

This commit is contained in:
kpcyrd
2020-03-15 15:39:41 +01:00
parent b548446759
commit 872d279c49
3 changed files with 10 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -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)",

View File

@@ -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"

View File

@@ -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(),