first cli (wip)
This commit is contained in:
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
extern crate serde;
|
||||
extern crate clap;
|
||||
|
||||
mod cli;
|
||||
mod config;
|
||||
mod planning;
|
||||
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use clap::Parser;
|
||||
use cli::Cli;
|
||||
use config::Config;
|
||||
use crate::cli::Commands::Planning;
|
||||
use crate::cli::Planning::I2work;
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
let default_config_path = PathBuf::from("/etc/config.toml");
|
||||
let config_path = match cli.config.as_deref() {
|
||||
Some(p) => p,
|
||||
None => &default_config_path
|
||||
};
|
||||
|
||||
let config_path_content = fs::read_to_string(config_path)
|
||||
.expect("Could not read config file");
|
||||
|
||||
let config: Config = toml::from_str(&*config_path_content).expect("Could not parse config");
|
||||
|
||||
match cli.command {
|
||||
Some(Planning(I2work(args))) => {
|
||||
planning::issue2work::issue2work(config, &args);
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user