Add --watch flag to the 'build' and 'docs' commands too.

This commit is contained in:
KtorZ 2023-11-25 14:52:51 +01:00
parent 7645a9460f
commit 40c0fa7d77
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 28 additions and 6 deletions

View File

@ -1,4 +1,4 @@
use aiken_project::watch::with_project;
use aiken_project::watch::{self, watch_project, with_project};
use std::path::PathBuf;
#[derive(clap::Args)]
@ -11,6 +11,10 @@ pub struct Args {
#[clap(short = 'D', long)]
deny: bool,
/// When enabled, re-run the command on file changes instead of exiting
#[clap(short, long)]
watch: bool,
/// Also dump textual uplc
#[clap(short, long)]
uplc: bool,
@ -24,11 +28,18 @@ pub fn exec(
Args {
directory,
deny,
watch,
uplc,
keep_traces,
}: Args,
) -> miette::Result<()> {
if watch {
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
p.build(uplc, keep_traces.into())
})
} else {
with_project(directory.as_deref(), deny, |p| {
p.build(uplc, keep_traces.into())
})
}
}

View File

@ -1,4 +1,4 @@
use aiken_project::watch::with_project;
use aiken_project::watch::{self, watch_project, with_project};
use std::path::PathBuf;
#[derive(clap::Args)]
@ -11,6 +11,10 @@ pub struct Args {
#[clap(short = 'D', long)]
deny: bool,
/// When enabled, re-run the command on file changes instead of exiting
#[clap(short, long)]
watch: bool,
/// Output directory for the documentation
#[clap(short = 'o', long)]
destination: Option<PathBuf>,
@ -20,8 +24,15 @@ pub fn exec(
Args {
directory,
deny,
watch,
destination,
}: Args,
) -> miette::Result<()> {
if watch {
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
p.docs(destination.clone())
})
} else {
with_project(directory.as_deref(), deny, |p| p.docs(destination.clone()))
}
}