Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cargo-style output diagnostics. #859

Merged
merged 1 commit into from
Jun 27, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- #869 - ensure cargo configuration environment variable flags are passed to the docker container.
- #859 - added color diagnostic output and error messages.

### Fixed

Expand Down
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ctrlc = { version = "3.2.2", features = ["termination"] }
directories = "4.0.1"
walkdir = { version = "2", optional = true }
tempfile = "3.3.0"
owo-colors = { version = "3.4.0", features = ["supports-colors"] }

[target.'cfg(not(windows))'.dependencies]
nix = { version = "0.24", default-features = false, features = ["user"] }
Expand Down
13 changes: 12 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@ unknown-git = "deny"
allow-git = []

[licenses]
# need this since to suppress errors in case we add crates with these allowed licenses
unused-allowed-license = "allow"
unlicensed = "deny"
allow-osi-fsf-free = "neither"
copyleft = "deny"
confidence-threshold = 0.93
allow = ["Apache-2.0", "MIT", "CC0-1.0"]
allow = [
"Apache-2.0",
"MIT",
"CC0-1.0",
"ISC",
"0BSD",
"BSD-2-Clause",
"BSD-3-Clause",
"Unlicense"
]

[licenses.private]
ignore = true
27 changes: 23 additions & 4 deletions src/bin/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ use std::fs;
use super::containers::*;
use super::images::*;
use clap::Args;
use cross::shell::{self, MessageInfo};

#[derive(Args, Debug)]
pub struct Clean {
/// Provide verbose diagnostic output.
#[clap(short, long)]
pub verbose: bool,
/// Do not print cross log messages.
#[clap(short, long)]
pub quiet: bool,
/// Whether messages should use color output.
#[clap(long)]
pub color: Option<String>,
/// Force removal of images.
#[clap(short, long)]
pub force: bool,
Expand All @@ -25,22 +32,28 @@ pub struct Clean {

impl Clean {
pub fn run(self, engine: cross::docker::Engine) -> cross::Result<()> {
let msg_info = MessageInfo::create(self.verbose, self.quiet, self.color.as_deref())?;
let tempdir = cross::temp::dir()?;
match self.execute {
true => {
if tempdir.exists() {
fs::remove_dir_all(tempdir)?;
}
}
false => println!(
"fs::remove_dir_all({})",
cross::pretty_path(&tempdir, |_| false)
),
false => shell::print(
format!(
"fs::remove_dir_all({})",
cross::pretty_path(&tempdir, |_| false)
),
msg_info,
)?,
}

// containers -> images -> volumes -> prune to ensure no conflicts.
let remove_containers = RemoveAllContainers {
verbose: self.verbose,
quiet: self.quiet,
color: self.color.clone(),
force: self.force,
execute: self.execute,
engine: None,
Expand All @@ -50,6 +63,8 @@ impl Clean {
let remove_images = RemoveImages {
targets: vec![],
verbose: self.verbose,
quiet: self.quiet,
color: self.color.clone(),
force: self.force,
local: self.local,
execute: self.execute,
Expand All @@ -59,6 +74,8 @@ impl Clean {

let remove_volumes = RemoveAllVolumes {
verbose: self.verbose,
quiet: self.quiet,
color: self.color.clone(),
force: self.force,
execute: self.execute,
engine: None,
Expand All @@ -67,6 +84,8 @@ impl Clean {

let prune_volumes = PruneVolumes {
verbose: self.verbose,
quiet: self.quiet,
color: self.color.clone(),
execute: self.execute,
engine: None,
};
Expand Down
Loading