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;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
|
@ -11,6 +11,10 @@ pub struct Args {
|
||||||
#[clap(short = 'D', long)]
|
#[clap(short = 'D', long)]
|
||||||
deny: bool,
|
deny: bool,
|
||||||
|
|
||||||
|
/// When enabled, re-run the command on file changes instead of exiting
|
||||||
|
#[clap(short, long)]
|
||||||
|
watch: bool,
|
||||||
|
|
||||||
/// Also dump textual uplc
|
/// Also dump textual uplc
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
uplc: bool,
|
uplc: bool,
|
||||||
|
@ -24,11 +28,18 @@ pub fn exec(
|
||||||
Args {
|
Args {
|
||||||
directory,
|
directory,
|
||||||
deny,
|
deny,
|
||||||
|
watch,
|
||||||
uplc,
|
uplc,
|
||||||
keep_traces,
|
keep_traces,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
with_project(directory.as_deref(), deny, |p| {
|
if watch {
|
||||||
p.build(uplc, keep_traces.into())
|
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;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
|
@ -11,6 +11,10 @@ pub struct Args {
|
||||||
#[clap(short = 'D', long)]
|
#[clap(short = 'D', long)]
|
||||||
deny: bool,
|
deny: bool,
|
||||||
|
|
||||||
|
/// When enabled, re-run the command on file changes instead of exiting
|
||||||
|
#[clap(short, long)]
|
||||||
|
watch: bool,
|
||||||
|
|
||||||
/// Output directory for the documentation
|
/// Output directory for the documentation
|
||||||
#[clap(short = 'o', long)]
|
#[clap(short = 'o', long)]
|
||||||
destination: Option<PathBuf>,
|
destination: Option<PathBuf>,
|
||||||
|
@ -20,8 +24,15 @@ pub fn exec(
|
||||||
Args {
|
Args {
|
||||||
directory,
|
directory,
|
||||||
deny,
|
deny,
|
||||||
|
watch,
|
||||||
destination,
|
destination,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
with_project(directory.as_deref(), deny, |p| p.docs(destination.clone()))
|
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