mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Cleanup install command
This commit is contained in:
parent
97b1550dda
commit
142f9a03fd
4 changed files with 56 additions and 51 deletions
|
@ -1,5 +1,7 @@
|
|||
#![allow(unreachable_pub)]
|
||||
|
||||
use crate::install::{ClientOpt, Malloc, ServerOpt};
|
||||
|
||||
xflags::args_parser! {
|
||||
/// Run custom build command.
|
||||
cmd xtask {
|
||||
|
@ -137,3 +139,34 @@ impl Xtask {
|
|||
}
|
||||
}
|
||||
// generated end
|
||||
|
||||
impl Install {
|
||||
pub(crate) fn validate(&self) -> xflags::Result<()> {
|
||||
if let Some(code_bin) = &self.code_bin {
|
||||
if let Err(err) = code_bin.parse::<ClientOpt>() {
|
||||
return Err(xflags::Error::new(format!("failed to parse `--code-bin`: {}", err)));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub(crate) fn server(&self) -> Option<ServerOpt> {
|
||||
if self.client && !self.server {
|
||||
return None;
|
||||
}
|
||||
let malloc = if self.mimalloc {
|
||||
Malloc::Mimalloc
|
||||
} else if self.jemalloc {
|
||||
Malloc::Jemalloc
|
||||
} else {
|
||||
Malloc::System
|
||||
};
|
||||
Some(ServerOpt { malloc })
|
||||
}
|
||||
pub(crate) fn client(&self) -> Option<ClientOpt> {
|
||||
if !self.client && self.server {
|
||||
return None;
|
||||
}
|
||||
let client_opt = self.code_bin.as_ref().and_then(|it| it.parse().ok()).unwrap_or_default();
|
||||
Some(client_opt)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue