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-21 19:21:52 -04:00
|
|
|
#[clap(subcommand)]
|
2022-10-21 00:16:25 -04:00
|
|
|
command: Option<Commands>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subcommand)]
|
|
|
|
enum Commands {
|
|
|
|
/// displays version info about this program
|
2022-10-21 19:37:45 -04:00
|
|
|
Setup {},
|
2022-10-21 00:16:25 -04:00
|
|
|
}
|
|
|
|
|
2022-08-31 16:14:41 -04:00
|
|
|
fn main() {
|
2022-10-21 19:21:52 -04:00
|
|
|
// set the configuration file path depending on the OS
|
|
|
|
let mut config_path: &str = "/etc/zealot/config.toml";
|
|
|
|
if cfg!(windows) {
|
|
|
|
config_path = "C:\\Program Files\\Zealot\\config.toml";
|
|
|
|
}
|
|
|
|
|
2022-09-01 16:16:27 -04:00
|
|
|
// initialize the log4rs logger
|
|
|
|
log4rs::init_file("./log4rs.yaml", Default::default()).unwrap();
|
|
|
|
|
2022-10-21 00:16:25 -04:00
|
|
|
// initialize the clap CLI
|
|
|
|
let cli = Cli::parse();
|
|
|
|
|
|
|
|
match &cli.command {
|
|
|
|
// sub-commands will be handled here
|
2022-10-21 19:37:45 -04:00
|
|
|
Some(Commands::Setup {}) => cmd::core::setup_command(config_path),
|
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
|
|
|
}
|