Revert "add error NoGroupFilesInArguments"
This partially reverts commit a4c900c9a7.
TODO.md is unaffected by this.
This commit is contained in:
+1
-7
@@ -27,17 +27,11 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
/// Skip printing the error chain when searching packages yields no results, otherwise report error
|
/// Skip printing the error chain when searching packages yields no results, otherwise report error
|
||||||
/// chain.
|
/// chain.
|
||||||
#[allow(clippy::option_if_let_else)]
|
|
||||||
fn handle_final_result(result: Result<()>) -> ExitCode {
|
fn handle_final_result(result: Result<()>) -> ExitCode {
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => ExitCode::SUCCESS,
|
Ok(_) => ExitCode::SUCCESS,
|
||||||
Err(ref e) => {
|
Err(ref e) => {
|
||||||
if let Some(pacdef_err) = e.root_cause().downcast_ref::<pacdef_core::Error>() {
|
if e.root_cause().to_string() == pacdef_core::Error::NoPackagesFound.to_string() {
|
||||||
match pacdef_err {
|
|
||||||
pacdef_core::Error::NoPackagesFound => (),
|
|
||||||
pacdef_core::Error::NoGroupFilesInArguments => eprintln!("{pacdef_err}"),
|
|
||||||
_ => eprintln!("unexpected error"),
|
|
||||||
};
|
|
||||||
ExitCode::FAILURE
|
ExitCode::FAILURE
|
||||||
} else {
|
} else {
|
||||||
result.report()
|
result.report()
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ fn get_group_cmd() -> Command {
|
|||||||
.short('e')
|
.short('e')
|
||||||
.long("edit")
|
.long("edit")
|
||||||
.help("edit the new group files after creation")
|
.help("edit the new group files after creation")
|
||||||
.action(clap::ArgAction::SetTrue)
|
.action(clap::ArgAction::SetTrue),
|
||||||
.num_args(0),
|
|
||||||
)
|
)
|
||||||
.arg(Arg::new("groups").num_args(1..).required(true))
|
.arg(Arg::new("groups").num_args(1..).required(true))
|
||||||
.visible_alias("n");
|
.visible_alias("n");
|
||||||
|
|||||||
@@ -315,9 +315,8 @@ fn get_group_file_paths_matching_args<'a>(
|
|||||||
groups: &'a HashSet<Group>,
|
groups: &'a HashSet<Group>,
|
||||||
) -> Result<Vec<&'a Path>> {
|
) -> Result<Vec<&'a Path>> {
|
||||||
let file_names: Vec<_> = arg_match
|
let file_names: Vec<_> = arg_match
|
||||||
.get_many::<String>("groups")
|
.get_many::<String>("group")
|
||||||
.context("getting groups from args")
|
.context("getting groups from args")?
|
||||||
.map_err(|_| crate::errors::Error::NoGroupFilesInArguments)?
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let name_group_map: HashMap<&str, &Group> =
|
let name_group_map: HashMap<&str, &Group> =
|
||||||
|
|||||||
@@ -7,15 +7,12 @@ use std::fmt::Display;
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Package search yields no results.
|
/// Package search yields no results.
|
||||||
NoPackagesFound,
|
NoPackagesFound,
|
||||||
/// No group files were provided as arguments.
|
|
||||||
NoGroupFilesInArguments,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::NoPackagesFound => f.write_str("no packages matching query"),
|
Self::NoPackagesFound => f.write_str("no packages matching query"),
|
||||||
Self::NoGroupFilesInArguments => f.write_str("no group files in arguments"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user