aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/flags.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-03-05 08:51:32 +0000
committerAleksey Kladov <[email protected]>2021-03-05 08:51:32 +0000
commit142f9a03fd4bad366439b18d8de7f2237bed65ab (patch)
treed57e4695c79e7485a1295adac9a2aafa20e9a3df /xtask/src/flags.rs
parent97b1550ddaf9599dada343aa960de02f0a06de2e (diff)
Cleanup install command
Diffstat (limited to 'xtask/src/flags.rs')
-rw-r--r--xtask/src/flags.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index 5710fbdb5..2ca05d3df 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -1,5 +1,7 @@
1#![allow(unreachable_pub)] 1#![allow(unreachable_pub)]
2 2
3use crate::install::{ClientOpt, Malloc, ServerOpt};
4
3xflags::args_parser! { 5xflags::args_parser! {
4 /// Run custom build command. 6 /// Run custom build command.
5 cmd xtask { 7 cmd xtask {
@@ -137,3 +139,34 @@ impl Xtask {
137 } 139 }
138} 140}
139// generated end 141// generated end
142
143impl Install {
144 pub(crate) fn validate(&self) -> xflags::Result<()> {
145 if let Some(code_bin) = &self.code_bin {
146 if let Err(err) = code_bin.parse::<ClientOpt>() {
147 return Err(xflags::Error::new(format!("failed to parse `--code-bin`: {}", err)));
148 }
149 }
150 Ok(())
151 }
152 pub(crate) fn server(&self) -> Option<ServerOpt> {
153 if self.client && !self.server {
154 return None;
155 }
156 let malloc = if self.mimalloc {
157 Malloc::Mimalloc
158 } else if self.jemalloc {
159 Malloc::Jemalloc
160 } else {
161 Malloc::System
162 };
163 Some(ServerOpt { malloc })
164 }
165 pub(crate) fn client(&self) -> Option<ClientOpt> {
166 if !self.client && self.server {
167 return None;
168 }
169 let client_opt = self.code_bin.as_ref().and_then(|it| it.parse().ok()).unwrap_or_default();
170 Some(client_opt)
171 }
172}