fix: restore printing of some error messages
We rely on some errors to just bubble up and get printed. By matching on result at the top level like this we blocked some error messages from being able to be printed. For me this showed up when `cargo run -- new thing/thing` printed nothing even when there was an existing `thing` folder. It has already been the pattern for sometime for some subcommands to handle calling process::exit(1) in situations where it needs to handle error reporting more specially. It may seem lame, hacky, or repetitive but it's easy to maintain and read.
This commit is contained in:
parent
2980e8e21d
commit
d5820bb20a
|
@ -57,4 +57,5 @@ pub fn exec(
|
|||
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|_| std::process::exit(1))
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ pub fn exec(
|
|||
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|_| std::process::exit(1))
|
||||
}
|
||||
|
||||
fn ask_schema(
|
||||
|
|
|
@ -52,4 +52,5 @@ pub fn exec(
|
|||
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|_| std::process::exit(1))
|
||||
}
|
||||
|
|
|
@ -52,4 +52,5 @@ pub fn exec(
|
|||
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|_| std::process::exit(1))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use aiken_project::watch::{self, watch_project, with_project};
|
||||
use std::path::PathBuf;
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
#[derive(clap::Args)]
|
||||
/// Build an Aiken project
|
||||
|
@ -33,7 +33,7 @@ pub fn exec(
|
|||
keep_traces,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
if watch {
|
||||
let result = if watch {
|
||||
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
|
||||
p.build(uplc, keep_traces.into())
|
||||
})
|
||||
|
@ -41,5 +41,7 @@ pub fn exec(
|
|||
with_project(directory.as_deref(), deny, |p| {
|
||||
p.build(uplc, keep_traces.into())
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
result.map_err(|_| process::exit(1))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use aiken_project::watch::{self, watch_project, with_project};
|
||||
use std::path::PathBuf;
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
#[derive(clap::Args)]
|
||||
/// Type-check an Aiken project
|
||||
|
@ -52,7 +52,7 @@ pub fn exec(
|
|||
..
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
if watch {
|
||||
let result = if watch {
|
||||
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
|
||||
p.check(
|
||||
skip_tests,
|
||||
|
@ -72,5 +72,7 @@ pub fn exec(
|
|||
(!no_traces).into(),
|
||||
)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
result.map_err(|_| process::exit(1))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use aiken_project::watch::{self, watch_project, with_project};
|
||||
use std::path::PathBuf;
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
#[derive(clap::Args)]
|
||||
/// Build the documentation for an Aiken project
|
||||
|
@ -28,11 +28,13 @@ pub fn exec(
|
|||
destination,
|
||||
}: Args,
|
||||
) -> miette::Result<()> {
|
||||
if watch {
|
||||
let 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()))
|
||||
}
|
||||
};
|
||||
|
||||
result.map_err(|_| process::exit(1))
|
||||
}
|
||||
|
|
|
@ -6,14 +6,13 @@ use cmd::{
|
|||
tx, uplc, Cmd,
|
||||
};
|
||||
use owo_colors::OwoColorize;
|
||||
use std::process;
|
||||
|
||||
mod cmd;
|
||||
|
||||
fn main() {
|
||||
fn main() -> miette::Result<()> {
|
||||
panic_handler();
|
||||
|
||||
let result = match Cmd::default() {
|
||||
match Cmd::default() {
|
||||
Cmd::New(args) => new::exec(args),
|
||||
Cmd::Fmt(args) => fmt::exec(args),
|
||||
Cmd::Build(args) => build::exec(args),
|
||||
|
@ -27,11 +26,6 @@ fn main() {
|
|||
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
|
||||
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),
|
||||
Cmd::Completion(sub_cmd) => completion::exec(sub_cmd),
|
||||
};
|
||||
|
||||
match result {
|
||||
Ok(()) => (),
|
||||
Err(_) => process::exit(1),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue