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