disable 'as dependency' if backend does not support it
This commit is contained in:
@@ -23,6 +23,8 @@ const SWITCHES_INSTALL: Switches = &["--sync"];
|
||||
const SWITCHES_MAKE_DEPENDENCY: Switches = &["--database", "--asdeps"];
|
||||
const SWITCHES_REMOVE: Switches = &["--remove", "--recursive"];
|
||||
|
||||
const SUPPORTS_AS_DEPENDENCY: bool = true;
|
||||
|
||||
impl Backend for Arch {
|
||||
impl_backend_constants!();
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ const SWITCHES_INSTALL: Switches = &["install"];
|
||||
const SWITCHES_MAKE_DEPENDENCY: Switches = &[]; // not needed
|
||||
const SWITCHES_REMOVE: Switches = &["remove"];
|
||||
|
||||
const SUPPORTS_AS_DEPENDENCY: bool = true;
|
||||
|
||||
impl Backend for Debian {
|
||||
impl_backend_constants!();
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ const SWITCHES_INSTALL: Switches = &["install"];
|
||||
const SWITCHES_MAKE_DEPENDENCY: Switches = &[]; // not needed
|
||||
const SWITCHES_REMOVE: Switches = &["uninstall"];
|
||||
|
||||
const SUPPORTS_AS_DEPENDENCY: bool = false;
|
||||
|
||||
impl Backend for Python {
|
||||
impl_backend_constants!();
|
||||
|
||||
|
||||
@@ -16,11 +16,14 @@ pub struct Rust {
|
||||
|
||||
const BINARY: Text = "cargo";
|
||||
const SECTION: Text = "rust";
|
||||
|
||||
const SWITCHES_INSTALL: Switches = &["install"];
|
||||
const SWITCHES_INFO: Switches = &["search", "--limit", "1"];
|
||||
const SWITCHES_MAKE_DEPENDENCY: Switches = &[];
|
||||
const SWITCHES_REMOVE: Switches = &["uninstall"];
|
||||
|
||||
const SUPPORTS_AS_DEPENDENCY: bool = false;
|
||||
|
||||
impl Backend for Rust {
|
||||
impl_backend_constants!();
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ pub trait Backend: Debug {
|
||||
}
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
||||
|
||||
fn supports_as_dependency(&self) -> bool;
|
||||
}
|
||||
|
||||
fn get_group_packages_map(
|
||||
|
||||
@@ -53,5 +53,9 @@ macro_rules! impl_backend_constants {
|
||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn supports_as_dependency(&self) -> bool {
|
||||
SUPPORTS_AS_DEPENDENCY
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -76,8 +76,9 @@ fn get_action_for_package(
|
||||
backend: &dyn Backend,
|
||||
) -> Result<ContinueWithReview> {
|
||||
loop {
|
||||
match ask_user_action_for_package()? {
|
||||
match ask_user_action_for_package(backend.supports_as_dependency())? {
|
||||
ReviewIntention::AsDependency => {
|
||||
assert!(!backend.supports_as_dependency());
|
||||
reviews.push(ReviewAction::AsDependency(package));
|
||||
break;
|
||||
}
|
||||
@@ -102,9 +103,15 @@ fn get_action_for_package(
|
||||
Ok(ContinueWithReview::Yes)
|
||||
}
|
||||
|
||||
fn ask_user_action_for_package() -> Result<ReviewIntention> {
|
||||
print!("assign to (g)roup, (d)elete, (s)kip, (i)nfo, (a)s dependency, (q)uit? ");
|
||||
fn ask_user_action_for_package(supports_as_dependency: bool) -> Result<ReviewIntention> {
|
||||
print!("assign to (g)roup, (d)elete, (s)kip, (i)nfo, ");
|
||||
|
||||
if supports_as_dependency {
|
||||
print!("(a)s dependency, ");
|
||||
}
|
||||
print!("(q)uit? ");
|
||||
stdout().lock().flush()?;
|
||||
|
||||
match read_single_char_from_terminal()? {
|
||||
'a' => Ok(ReviewIntention::AsDependency),
|
||||
'd' => Ok(ReviewIntention::Delete),
|
||||
|
||||
Reference in New Issue
Block a user