ff2mpv-rust/src/main.rs

26 lines
579 B
Rust
Raw Normal View History

use std::env;
use std::process;
2023-02-13 19:20:26 +01:00
use ff2mpv_rust::command::Command;
2023-02-13 19:20:26 +01:00
fn main() {
let mut args = env::args();
args.next(); // Skip binary path
2023-02-13 19:20:26 +01:00
let command_name = args.next().unwrap_or_default();
let command = get_command(&command_name);
if let Err(e) = command.execute() {
2023-03-14 12:25:43 +01:00
eprintln!("{e}");
2023-02-13 19:20:26 +01:00
process::exit(-1);
}
}
2023-02-13 19:20:26 +01:00
fn get_command(name: &str) -> Command {
match name {
"help" => Command::ShowHelp,
"manifest" => Command::ShowManifest,
"validate" => Command::ValidateConfig,
_ => Command::FF2Mpv,
2023-02-13 19:20:26 +01:00
}
}