Showing the changes to git-command (3 of 4 files). Show all
Unified · Split
| @@ -11,3 +11,4 @@ edition = "2018" · 10 unmodified lines | ||
| 11 | 11 | doctest = false |
| 12 | 12 | |
| 13 | 13 | [dependencies] |
| 14 | +git-testtools = { path = "../tests/tools" } | |
| @@ -1,2 +1,36 @@ | ||
| 1 | 1 | #![deny(rust_2018_idioms)] |
| 2 | 2 | #![forbid(unsafe_code)] |
| 3 | +#![allow(dead_code)] | |
| 4 | + | |
| 5 | +use std::ffi::OsString; | |
| 6 | + | |
| 7 | +pub struct Prepare { | |
| 8 | + command: OsString, | |
| 9 | + use_shell: bool, | |
| 10 | +} | |
| 11 | + | |
| 12 | +mod prepare { | |
| 13 | + use crate::Prepare; | |
| 14 | + | |
| 15 | + /// Builder | |
| 16 | + impl Prepare { | |
| 17 | + pub fn with_shell(mut self) -> Self { | |
| 18 | + self.use_shell = true; | |
| 19 | + self | |
| 20 | + } | |
| 21 | + } | |
| 22 | + | |
| 23 | + /// Finalization | |
| 24 | + impl Prepare { | |
| 25 | + pub fn spawn(self) -> std::io::Result<std::process::Child> { | |
| 26 | + todo!("create command and spawn that") | |
| 27 | + } | |
| 28 | + } | |
| 29 | +} | |
| 30 | + | |
| 31 | +pub fn prepare(cmd: impl Into<OsString>) -> Prepare { | |
| 32 | + Prepare { | |
| 33 | + command: cmd.into(), | |
| 34 | + use_shell: false, | |
| 35 | + } | |
| 36 | +} | |
| @@ -0,0 +1,20 @@ | ||
| 1 | +mod spawn { | |
| 2 | + #[test] | |
| 3 | + #[ignore] | |
| 4 | + fn direct_command_execution_searches_in_path() { | |
| 5 | + git_command::prepare(if cfg!(unix) { "ls" } else { "dir.exe" }) | |
| 6 | + .spawn() | |
| 7 | + .unwrap(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + mod with_shell { | |
| 11 | + #[test] | |
| 12 | + #[ignore] | |
| 13 | + fn command_in_path_with_args() { | |
| 14 | + git_command::prepare(if cfg!(unix) { "ls -l" } else { "dir.exe -a" }) | |
| 15 | + .with_shell() | |
| 16 | + .spawn() | |
| 17 | + .unwrap(); | |
| 18 | + } | |
| 19 | + } | |
| 20 | +} | |