#![warn(missing_docs)]
use std::env;
use clap::CommandFactory;
use xvc::{cli::XvcCLI, error::Result, Error};
fn main() -> Result<()> {
if env::var_os("COMPLETE").is_some() {
let current_dir = env::current_dir().ok();
let ran_completion = clap_complete::CompleteEnv::with_factory(XvcCLI::command)
.try_complete(env::args_os(), current_dir.as_deref())
.map_err(Error::from)?;
if ran_completion {
return Ok(());
} else {
eprintln!("Something is broken with completions. Please undefine COMPLETE environment variable (if there is one) and report this.");
return Err(Error::CompletionError);
}
}
let cli_opts = xvc::cli::XvcCLI::from_args_os(std::env::args_os())?;
xvc::cli::dispatch(cli_opts)?;
Ok(())
}