fix: update aiken new
This commit is contained in:
parent
7dc5392a81
commit
269cf8c13f
|
@ -15,32 +15,32 @@ pub struct Args {
|
||||||
|
|
||||||
pub struct Creator {
|
pub struct Creator {
|
||||||
root: PathBuf,
|
root: PathBuf,
|
||||||
src: PathBuf,
|
lib: PathBuf,
|
||||||
scripts: PathBuf,
|
validators: PathBuf,
|
||||||
project: PathBuf,
|
project_lib: PathBuf,
|
||||||
project_name: String,
|
project_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Creator {
|
impl Creator {
|
||||||
fn new(args: Args, project_name: String) -> Self {
|
fn new(args: Args, project_name: String) -> Self {
|
||||||
let root = args.name;
|
let root = args.name;
|
||||||
let src = root.join("src");
|
let lib = root.join("lib");
|
||||||
let scripts = src.join("scripts");
|
let validators = root.join("validators");
|
||||||
let project_name = project_name;
|
let project_name = project_name;
|
||||||
let project = src.join(&project_name);
|
let project_lib = lib.join(&project_name);
|
||||||
Self {
|
Self {
|
||||||
root,
|
root,
|
||||||
src,
|
lib,
|
||||||
scripts,
|
validators,
|
||||||
project,
|
project_lib,
|
||||||
project_name,
|
project_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self) -> miette::Result<()> {
|
fn run(&self) -> miette::Result<()> {
|
||||||
fs::create_dir_all(&self.src).into_diagnostic()?;
|
fs::create_dir_all(&self.lib).into_diagnostic()?;
|
||||||
fs::create_dir_all(&self.scripts).into_diagnostic()?;
|
fs::create_dir_all(&self.project_lib).into_diagnostic()?;
|
||||||
fs::create_dir_all(&self.project).into_diagnostic()?;
|
fs::create_dir_all(&self.validators).into_diagnostic()?;
|
||||||
|
|
||||||
self.aiken_toml()?;
|
self.aiken_toml()?;
|
||||||
self.context()?;
|
self.context()?;
|
||||||
|
@ -52,7 +52,7 @@ impl Creator {
|
||||||
|
|
||||||
fn always_true_script(&self) -> miette::Result<()> {
|
fn always_true_script(&self) -> miette::Result<()> {
|
||||||
write(
|
write(
|
||||||
self.scripts.join("always_true.ak"),
|
self.validators.join("always_true.ak"),
|
||||||
indoc! {"
|
indoc! {"
|
||||||
pub fn spend() -> Bool {
|
pub fn spend() -> Bool {
|
||||||
True
|
True
|
||||||
|
@ -63,7 +63,7 @@ impl Creator {
|
||||||
|
|
||||||
fn project(&self) -> miette::Result<()> {
|
fn project(&self) -> miette::Result<()> {
|
||||||
write(
|
write(
|
||||||
self.src.join(format!("{}.ak", self.project_name)),
|
self.lib.join(format!("{}.ak", self.project_name)),
|
||||||
indoc! {"
|
indoc! {"
|
||||||
pub type Datum {
|
pub type Datum {
|
||||||
something: String,
|
something: String,
|
||||||
|
@ -74,7 +74,7 @@ impl Creator {
|
||||||
|
|
||||||
fn context(&self) -> miette::Result<()> {
|
fn context(&self) -> miette::Result<()> {
|
||||||
write(
|
write(
|
||||||
self.project.join("context.ak"),
|
self.project_lib.join("context.ak"),
|
||||||
indoc! {"
|
indoc! {"
|
||||||
pub type ScriptContext(purpose) {
|
pub type ScriptContext(purpose) {
|
||||||
tx_info: TxInfo,
|
tx_info: TxInfo,
|
||||||
|
@ -143,8 +143,7 @@ pub fn exec(args: Args) -> miette::Result<()> {
|
||||||
|
|
||||||
validate_name(&project_name).into_diagnostic()?;
|
validate_name(&project_name).into_diagnostic()?;
|
||||||
|
|
||||||
let creator = Creator::new(args, project_name);
|
Creator::new(args, project_name).run()?;
|
||||||
creator.run()?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue