diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.rs | 10 | ||||
-rw-r--r-- | src/commands/dependencies_of.rs | 12 | ||||
-rw-r--r-- | src/commands/find_pkg.rs | 2 | ||||
-rw-r--r-- | src/commands/what_depends.rs | 8 | ||||
-rw-r--r-- | src/config/util.rs | 2 | ||||
-rw-r--r-- | src/package/dependency/mod.rs | 6 | ||||
-rw-r--r-- | src/package/dependency/system.rs | 32 | ||||
-rw-r--r-- | src/package/dependency/system_runtime.rs | 32 | ||||
-rw-r--r-- | src/package/package.rs | 34 | ||||
-rw-r--r-- | src/ui.rs | 14 | ||||
-rw-r--r-- | src/util/filters.rs | 63 |
11 files changed, 13 insertions, 202 deletions
@@ -6,8 +6,6 @@ use clap::crate_authors; use clap::crate_version; // Helper types to ship around stringly typed clap API. -pub const IDENT_DEPENDENCY_TYPE_SYSTEM: &'static str = "system"; -pub const IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME: &'static str = "system-runtime"; pub const IDENT_DEPENDENCY_TYPE_BUILD: &'static str = "build"; pub const IDENT_DEPENDENCY_TYPE_RUNTIME: &'static str = "runtime"; @@ -271,14 +269,10 @@ pub fn cli<'a>() -> App<'a> { .long("type") .value_name("DEPENDENCY_TYPE") .possible_values(&[ - IDENT_DEPENDENCY_TYPE_SYSTEM, - IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME, IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) .default_values(&[ - IDENT_DEPENDENCY_TYPE_SYSTEM, - IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME, IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) @@ -310,14 +304,10 @@ pub fn cli<'a>() -> App<'a> { .long("type") .value_name("DEPENDENCY_TYPE") .possible_values(&[ - IDENT_DEPENDENCY_TYPE_SYSTEM, - IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME, IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) .default_values(&[ - IDENT_DEPENDENCY_TYPE_SYSTEM, - IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME, IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) diff --git a/src/commands/dependencies_of.rs b/src/commands/dependencies_of.rs index 1addb94..355b41f 100644 --- a/src/commands/dependencies_of.rs +++ b/src/commands/dependencies_of.rs @@ -23,22 +23,16 @@ pub async fn dependencies_of<'a>(matches: &ArgMatches, config: &Configuration<'a let print_runtime_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_RUNTIME); let print_build_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_BUILD); - let print_sys_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_SYSTEM); - let print_sys_runtime_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME); - trace!("Printing packages with format = '{}', runtime: {}, build: {}, sys: {}, sys_rt: {}", + trace!("Printing packages with format = '{}', runtime: {}, build: {}", format, print_runtime_deps, - print_build_deps, - print_sys_deps, - print_sys_runtime_deps); + print_build_deps); crate::ui::print_packages(&mut stdout, format, iter, print_runtime_deps, - print_build_deps, - print_sys_deps, - print_sys_runtime_deps) + print_build_deps) } diff --git a/src/commands/find_pkg.rs b/src/commands/find_pkg.rs index b6c26a5..be35d43 100644 --- a/src/commands/find_pkg.rs +++ b/src/commands/find_pkg.rs @@ -43,8 +43,6 @@ pub async fn find_pkg<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo format, iter, true, - true, - true, true) } } diff --git a/src/commands/what_depends.rs b/src/commands/what_depends.rs index 268b543..fc2c125 100644 --- a/src/commands/what_depends.rs +++ b/src/commands/what_depends.rs @@ -13,16 +13,12 @@ pub async fn what_depends<'a>(matches: &ArgMatches, config: &Configuration<'a>, let print_runtime_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_RUNTIME); let print_build_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_BUILD); - let print_sys_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_SYSTEM); - let print_sys_runtime_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_SYSTEM_RUNTIME); let package_filter = { let name = matches.value_of("package_name").map(String::from).map(PackageName::from).unwrap(); crate::util::filters::build_package_filter_by_dependency_name( &name, - print_sys_deps, - print_sys_runtime_deps, print_build_deps, print_runtime_deps ) @@ -42,8 +38,6 @@ pub async fn what_depends<'a>(matches: &ArgMatches, config: &Configuration<'a>, format, packages.into_iter(), print_runtime_deps, - print_build_deps, - print_sys_deps, - print_sys_runtime_deps) + print_build_deps) } diff --git a/src/config/util.rs b/src/config/util.rs index ecd94c8..60709e2 100644 --- a/src/config/util.rs +++ b/src/config/util.rs @@ -6,8 +6,6 @@ pub fn default_package_print_format() -> String { String::from(indoc::indoc!(r#" {{i}} - {{p.name}} : {{p.version}} {{#each p.sources}}Source: {{this.url}} - {{this.hash.hash}} ({{this.hash.type}}){{/each}} - {{#if print_system_deps}}System Deps: {{ p.dependencies.system }} {{/if}} - {{#if print_system_runtime_deps}}System runtime Deps: {{ p.dependencies.system_runtime }} {{/if}} {{#if print_build_deps}}Build Deps: {{ p.dependencies.build }} {{/if}} {{#if print_runtime_deps}}Runtime Deps: {{ p.dependencies.runtime }} {{/if}} diff --git a/src/package/dependency/mod.rs b/src/package/dependency/mod.rs index 6d4cb81..248ebb4 100644 --- a/src/package/dependency/mod.rs +++ b/src/package/dependency/mod.rs @@ -12,12 +12,6 @@ pub use build::*; mod runtime; pub use runtime::*; -mod system; -pub use system::*; - -mod system_runtime; -pub use system_runtime::*; - pub trait StringEqual { fn str_equal(&self, s: &str) -> bool; } diff --git a/src/package/dependency/system.rs b/src/package/dependency/system.rs deleted file mode 100644 index 689f0d8..0000000 --- a/src/package/dependency/system.rs +++ /dev/null @@ -1,32 +0,0 @@ -use anyhow::Result; -use serde::Deserialize; -use serde::Serialize; - -use crate::package::PackageName; -use crate::package::PackageVersionConstraint; -use crate::package::dependency::ParseDependency; -use crate::package::dependency::StringEqual; - -/// A dependency that can be installed from the system and is only required during build -#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[serde(transparent)] -pub struct SystemBuildDependency(String); - -impl AsRef<str> for SystemBuildDependency { - fn as_ref(&self) -> &str { - self.0.as_ref() - } -} - -impl StringEqual for SystemBuildDependency { - fn str_equal(&self, s: &str) -> bool { - self.0 == s - } -} - -impl ParseDependency for SystemBuildDependency { - fn parse_as_name_and_version(&self) -> Result<(PackageName, PackageVersionConstraint)> { - crate::package::dependency::parse_package_dependency_string_into_name_and_version(&self.0) - } -} - diff --git a/src/package/dependency/system_runtime.rs b/src/package/dependency/system_runtime.rs deleted file mode 100644 index 17ef5d5..0000000 --- a/src/package/dependency/system_runtime.rs +++ /dev/null @@ -1,32 +0,0 @@ -use anyhow::Result; -use serde::Deserialize; -use serde::Serialize; - -use crate::package::PackageName; -use crate::package::PackageVersionConstraint; -use crate::package::dependency::ParseDependency; -use crate::package::dependency::StringEqual; - -/// A dependency that can be installed from the system and is required during runtime -#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[serde(transparent)] -pub struct SystemDependency(String); - -impl AsRef<str> for SystemDependency { - fn as_ref(&self) -> &str { - self.0.as_ref() - } -} - -impl StringEqual for SystemDependency { - fn str_equal(&self, s: &str) -> bool { - self.0 == s - } -} - -impl ParseDependency for SystemDependency { - fn parse_as_name_and_version(&self) -> Result<(PackageName, PackageVersionConstraint)> { - crate::package::dependency::parse_package_dependency_string_into_name_and_version(&self.0) - } -} - diff --git a/src/package/package.rs b/src/package/package.rs index 698b8b1..9e19079 100644 --- a/src/package/package.rs +++ b/src/package/package.rs @@ -73,30 +73,6 @@ impl Package { self.dependencies = dependencies; } - /// Get all dependencies of the package - /// - /// Either return the list of dependencies or, if available, run the dependencies_script to - /// read the dependencies from there. - pub fn get_all_dependencies<'a>(&'a self) -> impl Iterator<Item = Result<(PackageName, PackageVersionConstraint)>> + 'a { - self.get_system_dependencies().chain(self.get_self_packaged_dependencies()) - } - - pub fn get_system_dependencies<'a>(&'a self) -> impl Iterator<Item = Result<(PackageName, PackageVersionConstraint)>> + 'a { - let system_iter = self.dependencies() - .system() - .iter() - .cloned() - .map(|d| d.parse_as_name_and_version()); - - let system_runtime_iter = self.dependencies() - .system_runtime() - .iter() - .cloned() - .map(|d| d.parse_as_name_and_version()); - - system_iter.chain(system_runtime_iter) - } - pub fn get_self_packaged_dependencies<'a>(&'a self) -> impl Iterator<Item = Result<(PackageName, PackageVersionConstraint)>> + 'a { let build_iter = self.dependencies() .build() @@ -154,12 +130,6 @@ pub struct PackageFlags { #[derive(Clone, Debug, Serialize, Deserialize, Getters)] pub struct Dependencies { #[getset(get = "pub")] - system: Vec<SystemBuildDependency>, - - #[getset(get = "pub")] - system_runtime: Vec<SystemDependency>, - - #[getset(get = "pub")] build: Vec<BuildDependency>, #[getset(get = "pub")] @@ -170,8 +140,6 @@ pub struct Dependencies { impl Dependencies { pub fn empty() -> Self { Dependencies { - system: vec![], - system_runtime: vec![], build: vec![], runtime: vec![], } @@ -183,8 +151,6 @@ impl Dependencies { pub fn with_runtime_dependencies(runtime_dependencies: Vec<Dependency>) -> Self { Dependencies { - system: vec![], - system_runtime: vec![], build: vec![], runtime: runtime_dependencies, } @@ -25,9 +25,7 @@ pub fn print_packages<'a, I>(out: &mut dyn Write, format: &str, iter: I, print_runtime_deps: bool, - print_build_deps: bool, - print_sys_deps: bool, - print_sys_runtime_deps: bool) + print_build_deps: bool) -> Result<()> where I: Iterator<Item = &'a Package> { @@ -41,8 +39,6 @@ pub fn print_packages<'a, I>(out: &mut dyn Write, package, print_runtime_deps, print_build_deps, - print_sys_deps, - print_sys_runtime_deps )?; } @@ -55,8 +51,6 @@ fn print_package(out: &mut dyn Write, package: &Package, print_runtime_deps: bool, print_build_deps: bool, - print_sys_deps: bool, - print_sys_runtime_deps: bool ) -> Result<()> { @@ -72,12 +66,6 @@ fn print_package(out: &mut dyn Write, if print_build_deps { data.insert("print_build_deps", serde_json::Value::Bool(print_build_deps)); } - if print_sys_deps { - data.insert("print_system_deps", serde_json::Value::Bool(print_sys_deps)); - } - if print_sys_runtime_deps { - data.insert("print_system_runtime_deps", serde_json::Value::Bool(print_sys_runtime_deps)); - } hb.render("package", &data) .map_err(Error::from) diff --git a/src/util/filters.rs b/src/util/filters.rs index 613a600..32bb4f7 100644 --- a/src/util/filters.rs +++ b/src/util/filters.rs @@ -11,47 +11,11 @@ use crate::package::ParseDependency; /// Helper function to build a package filter based on some flags and the package version pub fn build_package_filter_by_dependency_name( name: &PackageName, - check_system_dep: bool, - check_system_runtime_dep: bool, check_build_dep: bool, check_runtime_dep: bool) -> impl filters::failable::filter::FailableFilter<Package, Error = Error> { let n = name.clone(); // clone, so we can move into closure - let filter_system_dep = move |p: &Package| -> Result<bool> { - trace!("Checking whether any system depenency of {:?} is '{}'", p, n); - Ok({ - check_system_dep && p.dependencies() - .system() - .iter() - .inspect(|d| trace!("Checking {:?}", d)) - .map(|d| d.parse_as_name_and_version()) - .map_ok(|(name, _)| name == n) - .collect::<Result<Vec<bool>>>()? - .into_iter() - .inspect(|b| trace!("found: {}", b)) - .any(|b| b) - }) - }; - - let n = name.clone(); // clone, so we can move into closure - let filter_system_runtime_dep = move |p: &Package| -> Result<bool> { - trace!("Checking whether any system runtime depenency of {:?} is '{}'", p, n); - Ok({ - check_system_runtime_dep && p.dependencies() - .system_runtime() - .iter() - .inspect(|d| trace!("Checking {:?}", d)) - .map(|d| d.parse_as_name_and_version()) - .map_ok(|(name, _)| name == n) - .collect::<Result<Vec<bool>>>()? - .into_iter() - .inspect(|b| trace!("found: {}", b)) - .any(|b| b) - }) - }; - - let n = name.clone(); // clone, so we can move into closure let filter_build_dep = move |p: &Package| -> Result<bool> { trace!("Checking whether any build depenency of {:?} is '{}'", p, n); Ok({ @@ -85,10 +49,7 @@ pub fn build_package_filter_by_dependency_name( }) }; - filter_system_dep - .or(filter_system_runtime_dep) - .or(filter_build_dep) - .or(filter_rt_dep) + filter_build_dep.or(filter_rt_dep) } pub fn build_package_filter_by_name(name: PackageName) -> impl filters::filter::Filter<Package> { @@ -144,7 +105,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, false); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, false); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -171,7 +132,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, false); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, false); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -198,7 +159,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, true); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, true); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -212,8 +173,6 @@ mod tests { assert_eq!(*p.name(), pname("a")); assert_eq!(*p.dependencies().runtime(), vec![Dependency::from(String::from("foo =2.0"))]); assert!(p.dependencies().build().is_empty()); - assert!(p.dependencies().system().is_empty()); - assert!(p.dependencies().system_runtime().is_empty()); } #[test] @@ -230,7 +189,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, false); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, false); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -256,7 +215,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, true); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, true); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -288,7 +247,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, true); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, true); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -302,8 +261,6 @@ mod tests { assert_eq!(*p.name(), pname("a")); assert_eq!(*p.dependencies().runtime(), vec![Dependency::from(String::from("foo =1")), Dependency::from(String::from("bar =1"))]); assert!(p.dependencies().build().is_empty()); - assert!(p.dependencies().system().is_empty()); - assert!(p.dependencies().system_runtime().is_empty()); } #[test] @@ -338,7 +295,7 @@ mod tests { let repo = Repository::from(btree); - let f = build_package_filter_by_dependency_name(&pname("foo"), false, false, false, true); + let f = build_package_filter_by_dependency_name(&pname("foo"), false, true); let found = repo.packages() .map(|p| f.filter(p).map(|b| (b, p))) @@ -354,8 +311,6 @@ mod tests { assert_eq!(*p.name(), pname("a")); assert_eq!(*p.dependencies().runtime(), vec![Dependency::from(String::from("foo =2")), Dependency::from(String::from("bar =3"))]); assert!(p.dependencies().build().is_empty()); - assert!(p.dependencies().system().is_empty()); - assert!(p.dependencies().system_runtime().is_empty()); } { @@ -363,8 +318,6 @@ mod tests { assert_eq!(*p.name(), pname("b")); assert_eq!(*p.dependencies().runtime(), vec![Dependency::from(String::from("foo =4")), Dependency::from(String::from("baz =5"))]); assert!(p.dependencies().build().is_empty()); - assert!(p.dependencies().system().is_empty()); - assert!(p.dependencies().system_runtime().is_empty()); } } |