aboutsummaryrefslogtreecommitdiff
path: root/release/src/cargo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'release/src/cargo.rs')
-rw-r--r--release/src/cargo.rs54
1 files changed, 49 insertions, 5 deletions
diff --git a/release/src/cargo.rs b/release/src/cargo.rs
index 1a4f79f20..0b28458e9 100644
--- a/release/src/cargo.rs
+++ b/release/src/cargo.rs
@@ -1,10 +1,8 @@
1//! Tools for working with Cargo. 1//! Tools for working with Cargo.
2 2
3use std::{ 3use std::ffi::OsStr;
4 ffi::OsStr, 4use std::path::{Path, PathBuf};
5 path::{Path, PathBuf}, 5use std::process::{Command, Stdio};
6 process::{Command, Stdio},
7};
8 6
9use anyhow::{bail, Context as _, Result}; 7use anyhow::{bail, Context as _, Result};
10use clap::ValueEnum as _; 8use clap::ValueEnum as _;
@@ -107,6 +105,17 @@ pub struct CargoArgsBuilder {
107 105
108impl CargoArgsBuilder { 106impl CargoArgsBuilder {
109 #[must_use] 107 #[must_use]
108 pub fn new() -> Self {
109 Self {
110 toolchain: None,
111 subcommand: String::new(),
112 target: None,
113 features: vec![],
114 args: vec![],
115 }
116 }
117
118 #[must_use]
110 pub fn toolchain<S>(mut self, toolchain: S) -> Self 119 pub fn toolchain<S>(mut self, toolchain: S) -> Self
111 where 120 where
112 S: Into<String>, 121 S: Into<String>,
@@ -192,3 +201,38 @@ impl CargoArgsBuilder {
192 args 201 args
193 } 202 }
194} 203}
204
205#[derive(Debug, Default)]
206pub struct CargoBatchBuilder {
207 commands: Vec<Vec<String>>,
208}
209
210impl CargoBatchBuilder {
211 #[must_use]
212 pub fn new() -> Self {
213 Self { commands: vec![] }
214 }
215
216 #[must_use]
217 pub fn command(mut self, args: Vec<String>) -> Self {
218 self.commands.push(args);
219 self
220 }
221
222 pub fn add_command(&mut self, args: Vec<String>) -> &mut Self {
223 self.commands.push(args);
224 self
225 }
226
227 #[must_use]
228 pub fn build(&self) -> Vec<String> {
229 let mut args = vec!["batch".to_string()];
230
231 for command in &self.commands {
232 args.push("---".to_string());
233 args.extend(command.clone());
234 }
235
236 args
237 }
238}