diff options
Diffstat (limited to 'src/cargo')
-rw-r--r-- | src/cargo/external.rs | 19 | ||||
-rw-r--r-- | src/cargo/internal.rs | 28 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/cargo/external.rs b/src/cargo/external.rs new file mode 100644 index 0000000..c956b68 --- /dev/null +++ b/src/cargo/external.rs | |||
@@ -0,0 +1,19 @@ | |||
1 | use std::{path::Path, process::Command}; | ||
2 | |||
3 | use crate::cli::Args; | ||
4 | |||
5 | pub fn clean_ext(path: &Path, cli: &Args) { | ||
6 | let mut args = vec!["clean", "--manifest-path", path.to_str().unwrap()]; | ||
7 | if cli.dry_run { | ||
8 | args.push("--dry-run"); | ||
9 | } | ||
10 | if cli.doc { | ||
11 | args.push("--doc"); | ||
12 | } | ||
13 | Command::new("cargo") | ||
14 | .args(args) | ||
15 | .spawn() | ||
16 | .unwrap() | ||
17 | .wait_with_output() | ||
18 | .unwrap(); | ||
19 | } | ||
diff --git a/src/cargo/internal.rs b/src/cargo/internal.rs new file mode 100644 index 0000000..b3e44e4 --- /dev/null +++ b/src/cargo/internal.rs | |||
@@ -0,0 +1,28 @@ | |||
1 | use std::path::Path; | ||
2 | |||
3 | use cargo::{ | ||
4 | core::Workspace, | ||
5 | ops::{clean, CleanOptions}, | ||
6 | util::{context::GlobalContext, interning::InternedString}, | ||
7 | CargoResult, | ||
8 | }; | ||
9 | |||
10 | use crate::cli::Args; | ||
11 | |||
12 | pub fn clean_int(path: &Path, cli: &Args) -> CargoResult<()> { | ||
13 | let gctx = GlobalContext::default()?; | ||
14 | |||
15 | let workspace = Workspace::new(path, &gctx)?; | ||
16 | |||
17 | let opts = CleanOptions { | ||
18 | gctx: &gctx, | ||
19 | spec: vec![], | ||
20 | targets: vec![], | ||
21 | profile_specified: false, | ||
22 | requested_profile: InternedString::new("dev"), | ||
23 | doc: cli.doc, | ||
24 | dry_run: cli.dry_run, | ||
25 | }; | ||
26 | |||
27 | clean(&workspace, &opts) | ||
28 | } | ||