#![allow(unreachable_pub)]
use std::path::PathBuf;
use ide_ssr::{SsrPattern, SsrRule};
use crate::cli::Verbosity;
xflags::xflags! {
src "./src/cli/flags.rs"
cmd rust-analyzer {
repeated -v, --verbose
optional -q, --quiet
optional --log-file path: PathBuf
optional --no-log-buffering
optional --wait-dbg
default cmd lsp-server {
optional --version
optional -h, --help
optional --print-config-schema
}
cmd parse {
optional --no-dump
}
cmd symbols {}
cmd highlight {
optional --rainbow
}
cmd analysis-stats
required path: PathBuf
{
optional --randomize
optional --parallel
optional --memory-usage
optional --source-stats
optional -o, --only path: String
optional --with-deps
optional --no-sysroot
optional --disable-build-scripts
optional --disable-proc-macros
optional --skip-inference
}
cmd diagnostics
required path: PathBuf
{
optional --disable-build-scripts
optional --disable-proc-macros
}
cmd ssr
repeated rule: SsrRule
{}
cmd search
repeated pattern: SsrPattern
{
optional --debug snippet: String
}
cmd proc-macro {}
cmd lsif
required path: PathBuf
{}
}
}
#[derive(Debug)]
pub struct RustAnalyzer {
pub verbose: u32,
pub quiet: bool,
pub log_file: Option<PathBuf>,
pub no_log_buffering: bool,
pub wait_dbg: bool,
pub subcommand: RustAnalyzerCmd,
}
#[derive(Debug)]
pub enum RustAnalyzerCmd {
LspServer(LspServer),
Parse(Parse),
Symbols(Symbols),
Highlight(Highlight),
AnalysisStats(AnalysisStats),
Diagnostics(Diagnostics),
Ssr(Ssr),
Search(Search),
ProcMacro(ProcMacro),
Lsif(Lsif),
}
#[derive(Debug)]
pub struct LspServer {
pub version: bool,
pub help: bool,
pub print_config_schema: bool,
}
#[derive(Debug)]
pub struct Parse {
pub no_dump: bool,
}
#[derive(Debug)]
pub struct Symbols;
#[derive(Debug)]
pub struct Highlight {
pub rainbow: bool,
}
#[derive(Debug)]
pub struct AnalysisStats {
pub path: PathBuf,
pub randomize: bool,
pub parallel: bool,
pub memory_usage: bool,
pub source_stats: bool,
pub only: Option<String>,
pub with_deps: bool,
pub no_sysroot: bool,
pub disable_build_scripts: bool,
pub disable_proc_macros: bool,
pub skip_inference: bool,
}
#[derive(Debug)]
pub struct Diagnostics {
pub path: PathBuf,
pub disable_build_scripts: bool,
pub disable_proc_macros: bool,
}
#[derive(Debug)]
pub struct Ssr {
pub rule: Vec<SsrRule>,
}
#[derive(Debug)]
pub struct Search {
pub pattern: Vec<SsrPattern>,
pub debug: Option<String>,
}
#[derive(Debug)]
pub struct ProcMacro;
#[derive(Debug)]
pub struct Lsif {
pub path: PathBuf,
}
impl RustAnalyzer {
pub const HELP: &'static str = Self::HELP_;
#[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)
}
}
impl RustAnalyzer {
pub fn verbosity(&self) -> Verbosity {
if self.quiet {
return Verbosity::Quiet;
}
match self.verbose {
0 => Verbosity::Normal,
1 => Verbosity::Verbose,
_ => Verbosity::Spammy,
}
}
}