2021-11-12 23:41:31 +01:00
|
|
|
use std::{process};
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
mod cli;
|
|
|
|
mod cmd;
|
|
|
|
pub mod console;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Get cli matches
|
|
|
|
let matches = cli::build_cli().get_matches();
|
|
|
|
|
|
|
|
// Read the config file
|
|
|
|
let config_file = match matches.value_of("config") {
|
|
|
|
Some(path) => PathBuf::from(path),
|
|
|
|
None => {
|
|
|
|
console::error("Error, not able to load config");
|
|
|
|
process::exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Start program flow
|
|
|
|
match matches.subcommand() {
|
|
|
|
("projects", Some(_matches)) => {
|
|
|
|
console::info("List of projects");
|
|
|
|
cmd::get_projects(&config_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
("tasks", Some(matches)) => {
|
2021-11-12 23:53:55 +01:00
|
|
|
console::info("List of tasks");
|
|
|
|
let project = matches.value_of("project")
|
|
|
|
.unwrap_or("0").trim().parse()
|
|
|
|
.expect("Type a number!");
|
|
|
|
cmd::get_tasks(&config_file, project);
|
2021-11-12 23:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_ => console::error("Whut!!!"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|