Add --watch flag to the 'build' and 'docs' commands too.
This commit is contained in:
parent
7645a9460f
commit
40c0fa7d77
|
@ -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())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue