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

feat(forge build -vvvvv): If verbosity level is 5 or higher show files to compile #9325

Merged
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 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 crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
comfy-table.workspace = true
dunce.workspace = true
eyre.workspace = true
itertools.workspace = true
num-format.workspace = true
reqwest.workspace = true
semver.workspace = true
Expand Down
22 changes: 22 additions & 0 deletions crates/common/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use foundry_compilers::{
artifacts::remappings::Remapping,
report::{self, BasicStdoutReporter, Reporter},
};
use foundry_config::find_project_root;
use itertools::Itertools;
use semver::Version;
use std::{
io,
Expand All @@ -17,6 +19,8 @@ use std::{
};
use yansi::Paint;

use crate::shell;

/// Some spinners
// https://github.com/gernest/wow/blob/master/spin/spinners.go
pub static SPINNERS: &[&[&str]] = &[
Expand Down Expand Up @@ -151,6 +155,24 @@ impl Drop for SpinnerReporter {

impl Reporter for SpinnerReporter {
fn on_compiler_spawn(&self, compiler_name: &str, version: &Version, dirty_files: &[PathBuf]) {
// Verbose message with dirty files displays first to avoid being overlapped
// by the spinner in .tick() which prints repeatedly over the same line.
if shell::verbosity() >= 5 {
let project_root = find_project_root(None);

self.send_msg(format!(
"Files to compile:\n{}",
dirty_files
.iter()
.map(|path| {
let trimmed_path = path.strip_prefix(&project_root).unwrap_or(path);
format!("- {}", trimmed_path.display())
})
.sorted()
.format("\n")
));
}

self.send_msg(format!(
"Compiling {} files with {} {}.{}.{}",
dirty_files.len(),
Expand Down
Loading