splitted src folder in several subfolders

This commit is contained in:
Nikolas Schmidt-Voigt 2021-09-05 21:43:33 +02:00
parent db6d4643cb
commit b21f0f013a
12 changed files with 31 additions and 28 deletions

View file

@ -1,9 +1,9 @@
use anyhow::Result;
use chrono::{naive, NaiveDate};
use crate::activity;
use crate::bartib_file;
use crate::output;
use crate::data::activity;
use crate::data::bartib_file;
use crate::view::output;
pub struct ActivityFilter {
pub number_of_activities: Option<usize>,

View file

@ -2,11 +2,11 @@ use anyhow::{anyhow, bail, Context, Error, Result};
use chrono::NaiveDateTime;
use std::process::Command;
use crate::activity;
use crate::bartib_file;
use crate::data::activity;
use crate::data::bartib_file;
use crate::conf;
use crate::format_util;
use crate::list_commands;
use crate::view::format_util;
use crate::controller;
// starts a new activity
pub fn start(
@ -71,7 +71,7 @@ pub fn continue_last_activity(
let mut file_content = bartib_file::get_file_content(file_name)?;
let optional_last_activity =
list_commands::get_last_activity_by_start(&file_content).or(list_commands::get_last_activity_by_end(&file_content));
controller::list::get_last_activity_by_start(&file_content).or(controller::list::get_last_activity_by_end(&file_content));
if let Some(last_activity) = optional_last_activity {
let new_activity = activity::Activity::start(

2
src/controller/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod list;
pub mod manipulation;

View file

@ -4,7 +4,7 @@ use std::io;
use std::io::{BufRead, BufReader, Write};
use std::str::FromStr;
use crate::activity;
use crate::data::activity;
pub enum LineStatus {
Unchanged,

2
src/data/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod activity;
pub mod bartib_file;

View file

@ -1,9 +1,5 @@
pub mod conf;
pub mod list_commands;
pub mod manipulation_commands;
pub mod controller;
mod activity;
mod bartib_file;
mod format_util;
mod output;
mod table;
mod data;
mod view;

View file

@ -170,7 +170,7 @@ fn run_subcommand(matches: &ArgMatches, file_name: &str) -> Result<()> {
let time = get_time_argument_or_ignore(sub_m.value_of("time"), "-t/--time")
.map(|t| Local::today().naive_local().and_time(t));
bartib::manipulation_commands::start(file_name, project_name, activity_description, time)
bartib::controller::manipulation::start(file_name, project_name, activity_description, time)
}
("continue", Some(sub_m)) => {
let project_name = sub_m.value_of("project");
@ -178,17 +178,17 @@ fn run_subcommand(matches: &ArgMatches, file_name: &str) -> Result<()> {
let time = get_time_argument_or_ignore(sub_m.value_of("time"), "-t/--time")
.map(|t| Local::today().naive_local().and_time(t));
bartib::manipulation_commands::continue_last_activity(file_name, project_name, activity_description, time)
bartib::controller::manipulation::continue_last_activity(file_name, project_name, activity_description, time)
}
("stop", Some(sub_m)) => {
let time = get_time_argument_or_ignore(sub_m.value_of("time"), "-t/--time")
.map(|t| Local::today().naive_local().and_time(t));
bartib::manipulation_commands::stop(file_name, time)
bartib::controller::manipulation::stop(file_name, time)
}
("current", Some(_)) => bartib::list_commands::list_running(file_name),
("current", Some(_)) => bartib::controller::list::list_running(file_name),
("list", Some(sub_m)) => {
let mut filter = bartib::list_commands::ActivityFilter {
let mut filter = bartib::controller::list::ActivityFilter {
number_of_activities: get_number_argument_or_ignore(
sub_m.value_of("number"),
"-n/--number",
@ -207,13 +207,13 @@ fn run_subcommand(matches: &ArgMatches, file_name: &str) -> Result<()> {
}
let do_group_activities = !sub_m.is_present("no_grouping") && !filter.date.is_some();
bartib::list_commands::list(file_name, filter, do_group_activities)
bartib::controller::list::list(file_name, filter, do_group_activities)
}
("projects", Some(_)) => bartib::list_commands::list_projects(file_name),
("last", Some(_)) => bartib::list_commands::display_last_activity(file_name),
("projects", Some(_)) => bartib::controller::list::list_projects(file_name),
("last", Some(_)) => bartib::controller::list::display_last_activity(file_name),
("edit", Some(sub_m)) => {
let optional_editor_command = sub_m.value_of("editor");
bartib::manipulation_commands::start_editor(file_name, optional_editor_command)
bartib::controller::manipulation::start_editor(file_name, optional_editor_command)
}
_ => bail!("Unknown command"),
}

3
src/view/mod.rs Normal file
View file

@ -0,0 +1,3 @@
pub mod format_util;
pub mod output;
pub mod table;

View file

@ -2,10 +2,10 @@ use chrono::NaiveDate;
use nu_ansi_term::Color;
use std::collections::BTreeMap;
use crate::activity;
use crate::data::activity;
use crate::conf;
use crate::format_util;
use crate::table;
use crate::view::format_util;
use crate::view::table;
// displays a table with activities
pub fn list_activities(activities: &[&activity::Activity], with_start_dates: bool) {