Gregory Ballantine
004c057a2c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
use clap::{Parser, Subcommand};
|
|
use log4rs;
|
|
use config::Config;
|
|
use transcoder::repository::Repository;
|
|
use transcoder::transcoder::Transcoder;
|
|
|
|
mod cmd;
|
|
mod settings;
|
|
mod transcoder;
|
|
mod util;
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author, version, about, long_about = None)]
|
|
struct Cli {
|
|
#[clap(subcommand)]
|
|
command: Option<Commands>,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// displays version info about this program
|
|
Setup {},
|
|
}
|
|
|
|
fn main() {
|
|
// 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";
|
|
}
|
|
|
|
// initialize the log4rs logger
|
|
log4rs::init_file("./log4rs.yaml", Default::default()).unwrap();
|
|
|
|
// initialize the clap CLI
|
|
let cli = Cli::parse();
|
|
|
|
match &cli.command {
|
|
// sub-commands will be handled here
|
|
Some(Commands::Setup {}) => cmd::core::setup_command(config_path),
|
|
|
|
// 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()));
|
|
|
|
// create and start the video transcoder object
|
|
let t: Transcoder = Transcoder::new(c, r);
|
|
t.start();
|
|
},
|
|
}
|
|
}
|