#![deny(warnings)]
#![deny(anonymous_parameters)]
#![deny(bare_trait_objects)]
#![deny(elided_lifetimes_in_paths)]
#![deny(missing_debug_implementations)]
#![deny(single_use_lifetimes)]
#![deny(trivial_casts)]
#![deny(trivial_numeric_casts)]
#![deny(unsafe_code)]
#![deny(unused_extern_crates)]
#![deny(unused_must_use)]
#![deny(unused_import_braces)]
#![deny(unused_imports)]
#[macro_use]
extern crate lazy_static;
mod args;
mod assets;
mod backup;
mod bars;
mod commit;
mod connection;
mod create;
mod delete;
#[macro_use]
mod fails;
mod fetch;
mod helpers;
mod information;
mod ingest;
mod models;
mod restore;
mod save;
mod state;
mod steps;
mod testsolr;
use crate::args::Cli;
use dotenvy::dotenv;
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv().ok();
let parsed = Cli::parse_from_args()?;
let result = wrangle::command_exec(&parsed);
if let Err(err) = result {
eprintln!("Error: {}", err);
return Err(err);
}
Ok(())
}
mod wrangle {
use crate::args::{Cli, Commands};
use crate::fails::{BoxedResult, throw};
use crate::{assets, backup, commit, create, delete, information, restore};
use clap::Parser;
pub(crate) fn command_exec(args: &Commands) -> Result<(), Box<dyn std::error::Error>> {
match args {
Commands::Backup(get) => backup::backup_main(get),
Commands::Restore(put) => restore::restore_main(put),
Commands::Commit(cmd) => commit::commit_main(cmd),
Commands::Delete(del) => delete::delete_main(del),
Commands::Create(cre) => create::create_main(cre),
Commands::Info(inf) => information::info_main(inf),
Commands::Generate(cpl) => assets::gen_assets(cpl),
}
}
impl Cli {
pub(crate) fn parse_from_args() -> BoxedResult<Commands> {
let parsed = Self::parse();
let cmds = parsed.arguments;
if let Err(msg) = cmds.validate() {
throw(msg)?;
}
cmds.get_logging().start_log()?;
Ok(cmds)
}
}
}