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
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(),
);
}
@@ -163,21 +162,18 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
}
});
format!(
"{}",
format!(
"{} | {} | {}",
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
.bold()
.to_string()),
pretty::style_if(styled, format!("{} passed", n_passed), |s| s
.bright_green()
.bold()
.to_string()),
pretty::style_if(styled, format!("{} failed", n_failed), |s| s
.bright_red()
.bold()
.to_string()),
)
"{} | {} | {}",
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
.bold()
.to_string()),
pretty::style_if(styled, format!("{} passed", n_passed), |s| s
.bright_green()
.bold()
.to_string()),
pretty::style_if(styled, format!("{} failed", n_failed), |s| s
.bright_red()
.bold()
.to_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),