Setup a web extension and refactor code
This commit is contained in:
37
src/main.rs
37
src/main.rs
@@ -3,22 +3,11 @@ extern crate reqwest;
|
||||
extern crate serde;
|
||||
extern crate simple_home_dir;
|
||||
|
||||
mod cli;
|
||||
mod config;
|
||||
mod debug;
|
||||
mod error;
|
||||
mod gitea;
|
||||
mod gitlab;
|
||||
mod openproject;
|
||||
mod planning;
|
||||
|
||||
use crate::cli::Commands::{Planning, Test};
|
||||
use crate::cli::Planning::I2work;
|
||||
use crate::error::GeneralError;
|
||||
use cl_cli::cli::Cli;
|
||||
use cl_cli::cli::Commands::{Planning, Test};
|
||||
use cl_cli::cli::Planning::I2work;
|
||||
use cl_cli::error::GeneralError;
|
||||
use clap::Parser;
|
||||
use cli::Cli;
|
||||
use config::Config;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
|
||||
@@ -34,22 +23,20 @@ async fn main() {
|
||||
None => &default_config_path,
|
||||
};
|
||||
|
||||
let config_path_content = match fs::read_to_string(config_path) {
|
||||
Ok(content) => content,
|
||||
let config = match cl_cli::config::build_config(config_path) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
println!(
|
||||
"Could not read config file at {:?}, error: {}",
|
||||
config_path, e
|
||||
);
|
||||
let general_error: GeneralError = e.into();
|
||||
println!("{}", general_error.description);
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let config: Config = toml::from_str(&*config_path_content).expect("Could not parse config");
|
||||
|
||||
let result = match cli.command {
|
||||
Some(Planning(I2work(args))) => planning::issue2work::issue2work(config, &args).await,
|
||||
Some(Test) => debug::debug(config).await,
|
||||
Some(Planning(I2work(args))) => {
|
||||
cl_cli::planning::issue2work::issue2work_cli(config, &args).await
|
||||
}
|
||||
Some(Test) => cl_cli::debug::debug(config).await,
|
||||
None => Err(GeneralError {
|
||||
description: "No command launched".to_string(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user