[feat]: print projects without quotes

This commit is contained in:
defigli 2024-05-21 20:47:21 +02:00 committed by Nikolas Schmidt-Voigt
parent f725201294
commit 3cdaa4cd7f
2 changed files with 15 additions and 3 deletions

View file

@ -163,7 +163,7 @@ pub fn check(file_name: &str) -> Result<()> {
}
// lists all projects
pub fn list_projects(file_name: &str, current: bool) -> Result<()> {
pub fn list_projects(file_name: &str, current: bool, no_quotes: bool) -> Result<()> {
let file_content = bartib_file::get_file_content(file_name)?;
let mut all_projects: Vec<&String> = getter::get_activities(&file_content)
@ -175,7 +175,11 @@ pub fn list_projects(file_name: &str, current: bool) -> Result<()> {
all_projects.dedup();
for project in all_projects {
println!("\"{project}\"");
if no_quotes {
println!("{project}");
} else {
println!("\"{project}\"");
}
}
Ok(())

View file

@ -234,6 +234,14 @@ fn main() -> Result<()> {
.help("prints currently running projects only")
.takes_value(false)
.required(false),
)
.arg(
Arg::with_name("no-quotes")
.short("n")
.long("no-quotes")
.help("prints projects without quotes")
.takes_value(false)
.required(false),
),
)
.subcommand(
@ -335,7 +343,7 @@ fn run_subcommand(matches: &ArgMatches, file_name: &str) -> Result<()> {
bartib::controller::report::show_report(file_name, filter, processors)
}
("projects", Some(sub_m)) => {
bartib::controller::list::list_projects(file_name, sub_m.is_present("current"))
bartib::controller::list::list_projects(file_name, sub_m.is_present("current"), sub_m.is_present("no-quotes"))
}
("last", Some(sub_m)) => {
let number = get_number_argument_or_ignore(sub_m.value_of("number"), "-n/--number")