Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/bin/cargo/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ pub fn cli() -> Command {
)
.value_name("SIZE")
.value_parser(parse_human_size),
)
.arg(
opt(
"max-target-dir-age",
"Deletes target directories that have not been used \
since the given age (unstable)",
)
.value_name("DURATION")
.value_parser(parse_time_span),
)
.arg(
opt(
"max-target-dir-size",
"Deletes target directories until the total size is under \
the given size (unstable)",
)
.value_name("SIZE")
.value_parser(parse_human_size),
),
)
.after_help(color_print::cstr!(
Expand Down Expand Up @@ -190,6 +208,8 @@ fn gc(gctx: &GlobalContext, args: &ArgMatches) -> CliResult {
max_crate_size: size_opt("max-crate-size"),
max_git_size: size_opt("max-git-size"),
max_download_size: size_opt("max-download-size"),
max_target_dir_age: duration_opt("max-target-dir-age"),
max_target_dir_size: size_opt("max-target-dir-size"),
};
if let Some(age) = duration_opt("max-download-age") {
gc_opts.set_max_download_age(age);
Expand Down
4 changes: 4 additions & 0 deletions src/cargo/core/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ pub struct GcOpts {
pub max_git_size: Option<u64>,
/// The `--max-download-size` CLI option.
pub max_download_size: Option<u64>,
/// The `--max-target-dir-age` CLI option.
pub max_target_dir_age: Option<Duration>,
/// The `--max-target-dir-size` CLI option.
pub max_target_dir_size: Option<u64>,
}

impl GcOpts {
Expand Down
Loading