Remove 'eval' command.

Was introduced as a work-around to get some debugging info out of scripts, but tests do now provide the same capability with a better output and, do so automatically.
This commit is contained in:
KtorZ 2022-12-14 22:10:15 +01:00
parent 978a6c6981
commit e5972640d2
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
7 changed files with 18 additions and 63 deletions

View File

@ -1,27 +0,0 @@
use aiken_project::options::{CodeGenMode, Options};
use std::path::PathBuf;
#[derive(clap::Args)]
/// Evaluate a chosen function with no argument.
pub struct Args {
/// Path to project
#[clap(short, long)]
directory: Option<PathBuf>,
/// Evaluate the given function
#[clap(short, long)]
function_name: String,
}
pub fn exec(
Args {
directory,
function_name,
}: Args,
) -> miette::Result<()> {
crate::with_project(directory, |p| {
p.compile(Options {
code_gen_mode: CodeGenMode::Eval(function_name.clone()),
})
})
}

View File

@ -1,7 +1,6 @@
pub mod build;
pub mod check;
pub mod error;
pub mod eval;
pub mod fmt;
pub mod lsp;
pub mod new;

View File

@ -34,16 +34,15 @@ where
err.report();
println!("{}", "Summary".purple().bold());
println!(
" {}, {}",
format!("{} error(s)", err.len()),
" {} error(s), {}",
err.len(),
format!("{warning_count} warning(s)").yellow(),
);
process::exit(1);
} else {
println!("{}", "Summary".purple().bold());
println!(
" {}, {}",
"0 error",
" 0 error, {}",
format!("{warning_count} warning(s)").yellow(),
);
}
@ -162,8 +161,6 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
(n_passed, n_failed + 1)
}
});
format!(
"{}",
format!(
"{} | {} | {}",
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
@ -178,7 +175,6 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
.bold()
.to_string()),
)
)
}
fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
@ -207,9 +203,7 @@ fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
fn group_by_module(infos: &Vec<EvalInfo>) -> BTreeMap<String, Vec<&EvalInfo>> {
let mut modules = BTreeMap::new();
for eval_info in infos {
let xs = modules
.entry(eval_info.script.module.clone())
.or_insert(vec![]);
let xs: &mut Vec<&EvalInfo> = modules.entry(eval_info.script.module.clone()).or_default();
xs.push(eval_info);
}
modules

View File

@ -1,4 +1,4 @@
use aiken::cmd::{build, check, eval, fmt, lsp, new, tx, uplc};
use aiken::cmd::{build, check, fmt, lsp, new, tx, uplc};
use clap::Parser;
/// Aiken: a smart-contract language and toolchain for Cardano
@ -11,7 +11,6 @@ pub enum Cmd {
Fmt(fmt::Args),
Build(build::Args),
Check(check::Args),
Eval(eval::Args),
#[clap(hide = true)]
Lsp(lsp::Args),
@ -36,7 +35,6 @@ fn main() -> miette::Result<()> {
Cmd::Fmt(args) => fmt::exec(args),
Cmd::Build(args) => build::exec(args),
Cmd::Check(args) => check::exec(args),
Cmd::Eval(args) => eval::exec(args),
Cmd::Lsp(args) => lsp::exec(args),
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),

View File

@ -94,7 +94,7 @@ impl TypedFunction {
left,
right,
..
} if tipo == &bool() => Some((name.clone(), left.clone(), right.clone())),
} if tipo == &bool() => Some((*name, left.clone(), right.clone())),
_ => None,
}
}

View File

@ -178,14 +178,6 @@ where
Ok(())
}
}
CodeGenMode::Eval(func_name) => {
let scripts = self
.collect_scripts(&checked_modules, |def| matches!(def, Definition::Fn(..)))?;
let results = self.eval_scripts(scripts, Some(func_name));
self.event_listener
.handle_event(Event::EvaluatingFunction { results });
Ok(())
}
CodeGenMode::NoOp => Ok(()),
}
}

View File

@ -4,7 +4,6 @@ pub struct Options {
pub enum CodeGenMode {
Test(Option<String>),
Eval(String),
Build(bool),
NoOp,
}