Skip to content
Snippets Groups Projects
Verified Commit 3f650098 authored by nfontrod's avatar nfontrod
Browse files

src/delete.rs: handle_arguments_value function uses prune::get_str & prune::string_convert function

parent b708ae81
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ use std::{ ...@@ -5,7 +5,7 @@ use std::{
process::{exit, Command, Stdio}, process::{exit, Command, Stdio},
}; };
use crate::commit; use crate::{commit, prune};
#[derive(Debug, Args)] #[derive(Debug, Args)]
pub(crate) struct Delete { pub(crate) struct Delete {
/// Do not change the repository /// Do not change the repository
...@@ -87,7 +87,7 @@ pub(crate) struct Delete { ...@@ -87,7 +87,7 @@ pub(crate) struct Delete {
help_heading = "Archive filters", help_heading = "Archive filters",
display_order = 4 display_order = 4
)] )]
pub(crate) first: Option<isize>, pub(crate) first: Option<usize>,
/// consider last N archives after other filters were applied /// consider last N archives after other filters were applied
#[clap( #[clap(
long, long,
...@@ -95,7 +95,7 @@ pub(crate) struct Delete { ...@@ -95,7 +95,7 @@ pub(crate) struct Delete {
help_heading = "Archive filters", help_heading = "Archive filters",
display_order = 5 display_order = 5
)] )]
pub(crate) last: Option<isize>, pub(crate) last: Option<usize>,
/// Name of archives to delete /// Name of archives to delete
#[clap( #[clap(
help_heading = "Positional Arguments", help_heading = "Positional Arguments",
...@@ -159,20 +159,11 @@ fn handle_force_arguments(margs: &mut Vec<String>, sd: &Delete) { ...@@ -159,20 +159,11 @@ fn handle_force_arguments(margs: &mut Vec<String>, sd: &Delete) {
/// A boolean indicating if Archive filters are used. Also Update `margs` parameter /// A boolean indicating if Archive filters are used. Also Update `margs` parameter
fn handle_arguments_value(margs: &mut Vec<String>, sd: &Delete) -> bool { fn handle_arguments_value(margs: &mut Vec<String>, sd: &Delete) -> bool {
let va: HM<&str, String> = HM::from([ let va: HM<&str, String> = HM::from([
("--prefix", sd.prefix.clone().unwrap_or(String::from(""))), ("--prefix", prune::get_str(&sd.prefix)),
( ("--glob-archives", prune::get_str(&sd.glob_archives)),
"--glob-archives", ("--sort-by", prune::get_str(&sd.sort_by)),
sd.glob_archives.clone().unwrap_or(String::from("")), ("--first", prune::string_convert(sd.first)),
), ("--last", prune::string_convert(sd.last)),
("--sort-by", sd.sort_by.clone().unwrap_or(String::from(""))),
(
"--first",
sd.first.unwrap_or(-1).to_string().replace("-1", ""),
),
(
"--last",
sd.last.unwrap_or(-1).to_string().replace("-1", ""),
),
]); ]);
let mut count = 0; let mut count = 0;
for (name, value) in va { for (name, value) in va {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment