diff --git a/src/bin/dockertags.rs b/src/bin/dockertags.rs index e743341..df36d67 100644 --- a/src/bin/dockertags.rs +++ b/src/bin/dockertags.rs @@ -23,7 +23,7 @@ fn main() { let args = Args::parse(); let query_args = QueryArgs::new(args.repository.as_str(), args.filter, args.arch); let config = docker_config::read_config(); - let tags = match config { + let mut tags = match config { None => { let fetcher = DockerHubTagsFetcher::new(); fetcher.get_tags(&query_args) @@ -33,6 +33,7 @@ fn main() { fetcher.get_tags(&query_args) } }; + tags.sort(); for tag in tags { let _ = writeln!(std::io::stdout(), "{}", &tag); } diff --git a/src/docker_hub.rs b/src/docker_hub.rs index 6d2be9e..b0e1085 100644 --- a/src/docker_hub.rs +++ b/src/docker_hub.rs @@ -93,7 +93,6 @@ impl DockerTagsFetcher for DockerHubTagsFetcher { for x in &filtered { results.push(x.name.clone().unwrap()); } - results.sort(); results } } \ No newline at end of file diff --git a/src/registry.rs b/src/registry.rs index 2dea259..7dba8ea 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -44,6 +44,11 @@ impl DockerTagsFetcher for RegistryTagsFetcher { None => { results.push(format!("Image not found: {}/{}", namespace, repository)); } } }; + if args.name.is_some() { + let pat = args.name.clone().unwrap(); + results = results.into_iter().filter(|x| x.contains(&pat)) + .collect::>(); + }; results } }