2022-10-21 00:16:25 -04:00
|
|
|
use clap::{Parser, Subcommand};
|
2022-09-01 16:16:27 -04:00
|
|
|
use log4rs;
|
2022-08-31 16:14:41 -04:00
|
|
|
use config::Config;
|
2022-09-01 22:15:46 -04:00
|
|
|
use transcoder::repository::Repository;
|
|
|
|
use transcoder::transcoder::Transcoder;
|
2022-08-31 16:14:41 -04:00
|
|
|
|
2022-10-21 19:21:52 -04:00
|
|
|
mod cmd;
|
2022-09-15 18:10:42 -04:00
|
|
|
mod settings;
|
2022-08-31 16:14:41 -04:00
|
|
|
mod transcoder;
|
2022-09-01 22:15:46 -04:00
|
|
|
mod util;
|
2022-08-31 16:14:41 -04:00
|
|
|
|
2022-10-21 00:16:25 -04:00
|
|
|
#[derive(Parser)]
|
2022-10-21 19:21:52 -04:00
|
|
|
#[clap(author, version, about, long_about = None)]
|
2022-10-21 00:16:25 -04:00
|
|
|
struct Cli {
|
2022-10-26 09:58:46 -04:00
|
|
|
/// Number of times to greet
|
|
|
|
#[clap(short = 'l', long, default_value_t = String::from("./log4rs.yaml"))]
|
|
|
|
log_config: String,
|
|
|
|
|
2022-10-21 19:21:52 -04:00
|
|
|
#[clap(subcommand)]
|
2022-10-21 00:16:25 -04:00
|
|
|
command: Option<Commands>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subcommand)]
|
|
|
|
enum Commands {
|
2023-04-01 22:55:51 -04:00
|
|
|
// Runs the setup command
|
2022-10-21 19:37:45 -04:00
|
|
|
Setup {},
|
2023-04-01 22:55:51 -04:00
|
|
|
|
|
|
|
// Displays version info about the program
|
|
|
|
Version {},
|
2022-10-21 00:16:25 -04:00
|
|
|
}
|
|
|
|
|
2022-08-31 16:14:41 -04:00
|
|
|
fn main() {
|
2022-10-21 00:16:25 -04:00
|
|
|
// initialize the clap CLI
|
|
|
|
let cli = Cli::parse();
|
|
|
|
|
2022-10-26 09:58:46 -04:00
|
|
|
// grab the log4rs config file path, then initialize log4rs
|
|
|
|
let log4rs_config: String = cli.log_config;
|
|
|
|
log4rs::init_file(&log4rs_config, Default::default()).unwrap();
|
|
|
|
|
2022-10-21 00:16:25 -04:00
|
|
|
match &cli.command {
|
|
|
|
// sub-commands will be handled here
|
2022-10-24 23:42:45 -04:00
|
|
|
Some(Commands::Setup {}) => cmd::core::setup_command(),
|
2023-04-01 22:55:51 -04:00
|
|
|
Some(Commands::Version {}) => cmd::core::version_command(),
|
2022-10-21 00:16:25 -04:00
|
|
|
|
|
|
|
// run the main program without any commands
|
|
|
|
None => {
|
|
|
|
// create and initialize our config and repository objects
|
|
|
|
let c: Config = settings::load_config();
|
|
|
|
let r: Repository = Repository::new(&shellexpand::tilde(&c.get_string("transcoder.repository").unwrap()));
|
2022-08-31 16:14:41 -04:00
|
|
|
|
2022-10-21 00:16:25 -04:00
|
|
|
// create and start the video transcoder object
|
|
|
|
let t: Transcoder = Transcoder::new(c, r);
|
|
|
|
t.start();
|
|
|
|
},
|
|
|
|
}
|
2022-08-31 16:14:41 -04:00
|
|
|
}
|