mod flags {
#![allow(unused)]
use std::path::PathBuf;
xflags::xflags! {
src "./examples/longer.rs"
cmd rust-analyzer {
repeated -v, --verbose
optional --log-file path: PathBuf
default cmd run-server {
optional --version
}
cmd parse {
optional --no-dump
}
cmd analysis-bench {
optional path: PathBuf
required --highlight path: PathBuf
optional --line num: u32
}
}
}
#[derive(Debug)]
pub struct RustAnalyzer {
pub verbose: u32,
pub log_file: Option<PathBuf>,
pub subcommand: RustAnalyzerCmd,
}
#[derive(Debug)]
pub enum RustAnalyzerCmd {
RunServer(RunServer),
Parse(Parse),
AnalysisBench(AnalysisBench),
}
#[derive(Debug)]
pub struct RunServer {
pub version: bool,
}
#[derive(Debug)]
pub struct Parse {
pub no_dump: bool,
}
#[derive(Debug)]
pub struct AnalysisBench {
pub path: Option<PathBuf>,
pub highlight: PathBuf,
pub line: Option<u32>,
}
impl RustAnalyzer {
#[allow(dead_code)]
pub fn from_env() -> xflags::Result<Self> {
Self::from_env_()
}
#[allow(dead_code)]
pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
Self::from_vec_(args)
}
}
}
fn main() {
match flags::RustAnalyzer::from_env() {
Ok(flags) => eprintln!("{:#?}", flags),
Err(err) => eprintln!("{}", err),
}
}