Rename --filter_traces to --trace_filter

It has somehow always annoyed me that we have --trace_level (with 'trace' first) and --filter_traces (with traces, plural and last). Given that these two options are almost always used together, the inconsistency is frustrating.
This commit is contained in:
KtorZ 2024-10-25 11:08:05 +02:00
parent 8e90a933c6
commit e97fe332b1
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
5 changed files with 25 additions and 25 deletions

View File

@ -8,7 +8,7 @@
### Changed ### Changed
- N/A - **aiken**: Rename `--filter_traces` to `--trace_filter` for more consistency with `--trace_level`. An alias for `--filter_traces` still exists for backward compatibility. @KtorZ
### Removed ### Removed

View File

@ -40,8 +40,8 @@ pub struct Args {
/// include both user-defined and compiler-generated traces. /// include both user-defined and compiler-generated traces.
/// ///
/// [optional] [default: all] /// [optional] [default: all]
#[clap(short, long, value_parser=filter_traces_parser(), default_missing_value="all", verbatim_doc_comment)] #[clap(short = 'f', long, value_parser=trace_filter_parser(), default_missing_value="all", verbatim_doc_comment, alias="filter_traces")]
filter_traces: Option<fn(TraceLevel) -> Tracing>, trace_filter: Option<fn(TraceLevel) -> Tracing>,
/// Choose the verbosity level of traces: /// Choose the verbosity level of traces:
/// ///
@ -65,7 +65,7 @@ pub fn exec(
deny, deny,
watch, watch,
uplc, uplc,
filter_traces, trace_filter,
trace_level, trace_level,
env, env,
}: Args, }: Args,
@ -74,8 +74,8 @@ pub fn exec(
watch_project(directory.as_deref(), watch::default_filter, 500, |p| { watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
p.build( p.build(
uplc, uplc,
match filter_traces { match trace_filter {
Some(filter_traces) => filter_traces(trace_level), Some(trace_filter) => trace_filter(trace_level),
None => Tracing::All(trace_level), None => Tracing::All(trace_level),
}, },
env.clone(), env.clone(),
@ -85,8 +85,8 @@ pub fn exec(
with_project(directory.as_deref(), deny, |p| { with_project(directory.as_deref(), deny, |p| {
p.build( p.build(
uplc, uplc,
match filter_traces { match trace_filter {
Some(filter_traces) => filter_traces(trace_level), Some(trace_filter) => trace_filter(trace_level),
None => Tracing::All(trace_level), None => Tracing::All(trace_level),
}, },
env.clone(), env.clone(),
@ -98,7 +98,7 @@ pub fn exec(
} }
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub fn filter_traces_parser( pub fn trace_filter_parser(
) -> MapValueParser<PossibleValuesParser, fn(String) -> fn(TraceLevel) -> Tracing> { ) -> MapValueParser<PossibleValuesParser, fn(String) -> fn(TraceLevel) -> Tracing> {
PossibleValuesParser::new(["user-defined", "compiler-generated", "all"]).map( PossibleValuesParser::new(["user-defined", "compiler-generated", "all"]).map(
|s: String| match s.as_str() { |s: String| match s.as_str() {

View File

@ -1,4 +1,4 @@
use super::build::{filter_traces_parser, trace_level_parser}; use super::build::{trace_filter_parser, trace_level_parser};
use aiken_lang::{ use aiken_lang::{
ast::{TraceLevel, Tracing}, ast::{TraceLevel, Tracing},
test_framework::PropertyTest, test_framework::PropertyTest,
@ -66,9 +66,9 @@ pub struct Args {
/// - all: /// - all:
/// include both user-defined and compiler-generated traces. /// include both user-defined and compiler-generated traces.
/// ///
/// [optional] [default: all] /// [default: all]
#[clap(short, long, value_parser=filter_traces_parser(), default_missing_value="all", verbatim_doc_comment)] #[clap(short = 'f', long, value_parser=trace_filter_parser(), default_missing_value="all", verbatim_doc_comment, alias="filter_traces")]
filter_traces: Option<fn(TraceLevel) -> Tracing>, trace_filter: Option<fn(TraceLevel) -> Tracing>,
/// Choose the verbosity level of traces: /// Choose the verbosity level of traces:
/// ///
@ -95,7 +95,7 @@ pub fn exec(
match_tests, match_tests,
exact_match, exact_match,
watch, watch,
filter_traces, trace_filter,
trace_level, trace_level,
seed, seed,
max_success, max_success,
@ -115,8 +115,8 @@ pub fn exec(
exact_match, exact_match,
seed, seed,
max_success, max_success,
match filter_traces { match trace_filter {
Some(filter_traces) => filter_traces(trace_level), Some(trace_filter) => trace_filter(trace_level),
None => Tracing::All(trace_level), None => Tracing::All(trace_level),
}, },
env.clone(), env.clone(),
@ -131,8 +131,8 @@ pub fn exec(
exact_match, exact_match,
seed, seed,
max_success, max_success,
match filter_traces { match trace_filter {
Some(filter_traces) => filter_traces(trace_level), Some(trace_filter) => trace_filter(trace_level),
None => Tracing::All(trace_level), None => Tracing::All(trace_level),
}, },
env.clone(), env.clone(),

View File

@ -1,4 +1,4 @@
use super::build::{filter_traces_parser, trace_level_parser}; use super::build::{trace_filter_parser, trace_level_parser};
use aiken_lang::ast::{TraceLevel, Tracing}; use aiken_lang::ast::{TraceLevel, Tracing};
use aiken_project::{options::Options, watch::with_project}; use aiken_project::{options::Options, watch::with_project};
use std::path::PathBuf; use std::path::PathBuf;
@ -33,8 +33,8 @@ pub struct Args {
/// include both user-defined and compiler-generated traces. /// include both user-defined and compiler-generated traces.
/// ///
/// [optional] [default: all] /// [optional] [default: all]
#[clap(short, long, value_parser=filter_traces_parser(), default_missing_value="all", verbatim_doc_comment)] #[clap(short = 'f', long, value_parser=trace_filter_parser(), default_missing_value="all", verbatim_doc_comment, alias = "filter_traces")]
filter_traces: Option<fn(TraceLevel) -> Tracing>, trace_filter: Option<fn(TraceLevel) -> Tracing>,
/// Choose the verbosity level of traces: /// Choose the verbosity level of traces:
/// ///
@ -57,7 +57,7 @@ pub fn exec(
directory, directory,
module, module,
name, name,
filter_traces, trace_filter,
trace_level, trace_level,
}: Args, }: Args,
) -> miette::Result<()> { ) -> miette::Result<()> {
@ -67,8 +67,8 @@ pub fn exec(
let export = p.export( let export = p.export(
&module, &module,
&name, &name,
match filter_traces { match trace_filter {
Some(filter_traces) => filter_traces(trace_level), Some(trace_filter) => trace_filter(trace_level),
None => Tracing::All(trace_level), None => Tracing::All(trace_level),
}, },
)?; )?;

View File

@ -1,8 +1,8 @@
use miette::IntoDiagnostic; use miette::IntoDiagnostic;
use owo_colors::{OwoColorize, Stream::Stderr}; use owo_colors::{OwoColorize, Stream::Stderr};
use pallas_primitives::{ use pallas_primitives::{
Fragment,
conway::{Redeemer, TransactionInput, TransactionOutput}, conway::{Redeemer, TransactionInput, TransactionOutput},
Fragment,
}; };
use pallas_traverse::{Era, MultiEraTx}; use pallas_traverse::{Era, MultiEraTx};
use std::{fmt, fs, path::PathBuf, process}; use std::{fmt, fs, path::PathBuf, process};