pub mod cli;
#[cfg(unix)]
mod control_cli;
pub mod producer;
#[cfg(target_os = "linux")]
pub mod linux;
use std::ffi::OsString;
use std::process::ExitCode;
use clap::Parser;
use crate::cli::Config;
pub fn main_entry<I, T>(arguments: I) -> ExitCode
where
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
{
let config = Config::parse_from(arguments);
if let Err(error) = config.validate() {
eprintln!("vvland: {error}");
return ExitCode::FAILURE;
}
#[cfg(unix)]
if let Some(crate::cli::Command::Msg(options)) = &config.command {
return match control_cli::run(options) {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("vvland: {error}");
ExitCode::FAILURE
}
};
}
#[cfg(target_os = "linux")]
{
match linux::run(config) {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("vvland: {error}");
ExitCode::FAILURE
}
}
}
#[cfg(not(target_os = "linux"))]
{
let _ = config;
eprintln!("vvland: this application is supported only on Linux");
ExitCode::FAILURE
}
}
pub fn print_deprecation_notice(old_name: &str, replacement: &str) {
use std::io::IsTerminal;
if std::io::stderr().is_terminal() {
eprintln!("{old_name}: deprecated; this is now a wrapper for `{replacement}`");
}
}