feat: add silent flag to all warning supression

This commit is contained in:
rvcas 2025-03-02 16:59:16 -05:00 committed by Lucas
parent 97c382715f
commit 0b1297f3b7
10 changed files with 32 additions and 12 deletions

View File

@ -91,6 +91,7 @@ pub fn default_filter(evt: &Event) -> bool {
pub fn with_project<A>( pub fn with_project<A>(
directory: Option<&Path>, directory: Option<&Path>,
deny: bool, deny: bool,
silent: bool,
json: bool, json: bool,
mut action: A, mut action: A,
) -> miette::Result<()> ) -> miette::Result<()>
@ -122,10 +123,12 @@ where
let warning_count = warnings.len(); let warning_count = warnings.len();
if !json { if !json {
if !silent {
for warning in &warnings { for warning in &warnings {
eprintln!(); eprintln!();
warning.report() warning.report()
} }
}
if let Err(errs) = build_result { if let Err(errs) = build_result {
for err in &errs { for err in &errs {
@ -156,7 +159,7 @@ where
} }
} }
if warning_count > 0 && deny { if warning_count > 0 && deny && !silent {
Err(ExitFailure::into_report()) Err(ExitFailure::into_report())
} else { } else {
Ok(()) Ok(())
@ -249,7 +252,7 @@ where
.if_supports_color(Stderr, |s| s.bold()) .if_supports_color(Stderr, |s| s.bold())
.if_supports_color(Stderr, |s| s.purple()), .if_supports_color(Stderr, |s| s.purple()),
); );
with_project(directory, false, false, &mut action).unwrap_or(()) with_project(directory, false, false, false, &mut action).unwrap_or(())
} }
} }
} }

View File

@ -89,6 +89,7 @@ pub fn exec(
let result = with_project( let result = with_project(
directory.as_deref(), directory.as_deref(),
false, false,
false,
!io::stdout().is_terminal(), !io::stdout().is_terminal(),
|p| { |p| {
p.benchmark( p.benchmark(

View File

@ -46,7 +46,7 @@ pub fn exec(
mainnet, mainnet,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, false, |p| { with_project(directory.as_deref(), false, false, false, |p| {
let address = p.address( let address = p.address(
module.as_deref(), module.as_deref(),
validator.as_deref(), validator.as_deref(),

View File

@ -62,7 +62,7 @@ pub fn exec(
validator, validator,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(None, false, false, |p| { with_project(None, false, false, false, |p| {
eprintln!( eprintln!(
"{} blueprint", "{} blueprint",
" Analyzing" " Analyzing"

View File

@ -36,7 +36,7 @@ pub fn exec(
validator, validator,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, false, |p| { with_project(directory.as_deref(), false, false, false, |p| {
let address = p.address( let address = p.address(
module.as_deref(), module.as_deref(),
validator.as_deref(), validator.as_deref(),

View File

@ -36,7 +36,7 @@ pub fn exec(
validator, validator,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, false, |p| { with_project(directory.as_deref(), false, false, false, |p| {
let policy = p.policy( let policy = p.policy(
module.as_deref(), module.as_deref(),
validator.as_deref(), validator.as_deref(),

View File

@ -13,6 +13,10 @@ pub struct Args {
#[clap(short = 'D', long)] #[clap(short = 'D', long)]
deny: bool, deny: bool,
/// Silence warnings; warnings will not be printed
#[clap(short = 'S', long)]
silent: bool,
/// When enabled, re-run the command on file changes instead of exiting /// When enabled, re-run the command on file changes instead of exiting
#[clap(short, long)] #[clap(short, long)]
watch: bool, watch: bool,
@ -75,6 +79,7 @@ pub fn exec(
Args { Args {
directory, directory,
deny, deny,
silent,
watch, watch,
uplc, uplc,
trace_filter, trace_filter,
@ -96,7 +101,7 @@ pub fn exec(
) )
}) })
} else { } else {
with_project(directory.as_deref(), deny, false, |p| { with_project(directory.as_deref(), deny, silent, false, |p| {
p.build( p.build(
uplc, uplc,
match trace_filter { match trace_filter {

View File

@ -35,6 +35,10 @@ pub struct Args {
#[clap(short = 'D', long)] #[clap(short = 'D', long)]
deny: bool, deny: bool,
/// Silence warnings; warnings will not be printed
#[clap(short = 'S', long)]
silent: bool,
/// Skip tests; run only the type-checker /// Skip tests; run only the type-checker
#[clap(short, long)] #[clap(short, long)]
skip_tests: bool, skip_tests: bool,
@ -108,6 +112,7 @@ pub fn exec(
Args { Args {
directory, directory,
deny, deny,
silent,
skip_tests, skip_tests,
debug, debug,
show_json_schema, show_json_schema,
@ -150,6 +155,7 @@ pub fn exec(
with_project( with_project(
directory.as_deref(), directory.as_deref(),
deny, deny,
silent,
!io::stdout().is_terminal(), !io::stdout().is_terminal(),
|p| { |p| {
p.check( p.check(

View File

@ -11,6 +11,10 @@ pub struct Args {
#[clap(short = 'D', long)] #[clap(short = 'D', long)]
deny: bool, deny: bool,
/// Silence warnings; warnings will not be printed
#[clap(short = 'S', long)]
silent: bool,
/// When enabled, re-run the command on file changes instead of exiting /// When enabled, re-run the command on file changes instead of exiting
#[clap(short, long)] #[clap(short, long)]
watch: bool, watch: bool,
@ -28,6 +32,7 @@ pub fn exec(
Args { Args {
directory, directory,
deny, deny,
silent,
watch, watch,
destination, destination,
include_dependencies, include_dependencies,
@ -38,7 +43,7 @@ pub fn exec(
p.docs(destination.clone(), include_dependencies) p.docs(destination.clone(), include_dependencies)
}) })
} else { } else {
with_project(directory.as_deref(), deny, false, |p| { with_project(directory.as_deref(), deny, silent, false, |p| {
p.docs(destination.clone(), include_dependencies) p.docs(destination.clone(), include_dependencies)
}) })
}; };

View File

@ -61,7 +61,7 @@ pub fn exec(
trace_level, trace_level,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
with_project(directory.as_deref(), false, false, |p| { with_project(directory.as_deref(), false, false, false, |p| {
p.compile(Options::default())?; p.compile(Options::default())?;
let export = p.export( let export = p.export(