From 93dfa39766b7470000e0de32ec2fc1b450c6e2a5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 24 Jul 2020 15:59:01 +0200 Subject: Minor --- xtask/src/dist.rs | 27 +++++++++++++++++---------- xtask/src/main.rs | 7 ++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index c198c0907..01d903cde 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -13,17 +13,24 @@ use crate::{ project_root, }; -pub fn run_dist(nightly: bool, client_version: Option) -> Result<()> { - let dist = project_root().join("dist"); - rm_rf(&dist)?; - fs2::create_dir_all(&dist)?; - - if let Some(version) = client_version { - let release_tag = if nightly { "nightly".to_string() } else { date_iso()? }; - dist_client(&version, &release_tag)?; +pub struct DistCmd { + pub nightly: bool, + pub client_version: Option, +} + +impl DistCmd { + pub fn run(self) -> Result<()> { + let dist = project_root().join("dist"); + rm_rf(&dist)?; + fs2::create_dir_all(&dist)?; + + if let Some(version) = self.client_version { + let release_tag = if self.nightly { "nightly".to_string() } else { date_iso()? }; + dist_client(&version, &release_tag)?; + } + dist_server()?; + Ok(()) } - dist_server()?; - Ok(()) } fn dist_client(version: &str, release_tag: &str) -> Result<()> { diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 53d3ce3e7..fab984fc0 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -13,7 +13,7 @@ use std::env; use pico_args::Arguments; use xtask::{ codegen::{self, Mode}, - dist::run_dist, + dist::DistCmd, install::{ClientOpt, InstallCmd, Malloc, ServerOpt}, not_bash::pushd, pre_commit, project_root, @@ -115,7 +115,7 @@ FLAGS: let nightly = args.contains("--nightly"); let client_version: Option = args.opt_value_from_str("--client")?; args.finish()?; - run_dist(nightly, client_version) + DistCmd { nightly, client_version }.run() } _ => { eprintln!( @@ -133,7 +133,8 @@ SUBCOMMANDS: codegen install lint - dist" + dist + promote" ); Ok(()) } -- cgit v1.2.3