feat(export): implement basic command functionality

This commit is contained in:
rvcas
2024-03-01 11:32:36 -05:00
committed by Lucas
parent b63bd9b9e0
commit 7d67f1497c
4 changed files with 150 additions and 66 deletions

View File

@@ -1,14 +1,36 @@
use std::path::PathBuf;
use aiken_project::{options::Options, watch::with_project};
#[derive(clap::Args)]
pub struct Args {
/// Name of the validator's module within the project. Optional if there's only one validator
/// Path to project
directory: Option<PathBuf>,
/// Name of the function's module within the project
#[clap(short, long)]
module: String,
/// Name of the validator within the module. Optional if there's only one validator
/// Name of the function within the module
#[clap(short, long)]
name: String,
}
pub fn exec(args: Args) -> miette::Result<()> {
Ok(())
pub fn exec(
Args {
directory,
module,
name,
}: Args,
) -> miette::Result<()> {
with_project(directory.as_deref(), false, |p| {
p.compile(Options::default())?;
let raw_uplc = p.export(&module, &name)?;
println!("{}", raw_uplc);
Ok(())
})
.map_err(|_| std::process::exit(1))
}