sonro / narrate Goto Github PK
View Code? Open in Web Editor NEWRust CLI utility library. Error handling, status reporting, and exit codes.
License: Apache License 2.0
Rust CLI utility library. Error handling, status reporting, and exit codes.
License: Apache License 2.0
Current ExitCode
behaviour does not produce custom exit codes. Unless the underlying error is an Error
or CliError
, any calls to ExitCode::exit_code()
will just produce the default 70
.
Replace the ExitCode
trait with assigning exitcodes to an Error
.
Upgrade integration tests to check the entirity of the public API
colored::Color
enum should not be exposed to end users.
Rewrite readme to be more in line with how this particular library should be used. At the moment it is missing several parts of the API
ExitCode
implementationCliError
usageBREAKING CHANGE
Simplify ErrorWrap
API to sometthing more akin to:
possible_error()
.wrap(|| "error message")
.set_help("help message")?;
BREAKING CHANGE
Stop ErrorWrap
from being implemented outside of the crate.
The isatty
function only needs to be called once.
Add a library introduction and API overview in rustdoc to the crate root
Change the Error debug format to be more in line with anyhow.
BREAKING CHANGE
Hide Error::downcast
and Error::from_anyhow
behind an "anyhow" feature flag. These are currently the only public APIs using anyhow types. Moreover only publicly re-export anyhow
crate behind the feature flag.
This allows the default API to keep the implementation separate from the user and the "anyhow" feature-set to allow conversion between the two types.
Using narrate::{bail, error_from}
in a project that doesn't specify anyhow
as a dependency separately (regardless of if the anyhow
feature of narrate
is used) unconditionally triggers a compile error. (AFAIK this is a bug, as documentation doesn't specify that anyhow
must also be a dependency.)
Cargo.toml
[package]
name = "example"
version = "0.1.0"
edition = "2021"
[dependencies]
narrate = { version = "0.4.1", features = ["anyhow"] }
# The above line could also have simply been:
# narrate = "0.4.1"
src/main.rs
fn main() -> narrate::Result<()> {
narrate::bail!("this should compile");
}
cargo build
See the triggered compiler error:
error[E0433]: failed to resolve: use of undeclared crate or module `anyhow`
--> src/main.rs:2:5
|
2 | narrate::bail!("this should compile");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `anyhow`
|
= note: this error originates in the macro `$crate::error_from` which comes from the expansion of the macro `narrate::bail` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0433`.
error: could not compile `main` (bin "main") due to previous error
It seems that this issue stems from narrate
not unconditionally requiring anyhow
as a non-optional dependency. My best guess is that this was introduced in bdba927. This seems related to #4.
In the meantime while awaiting a fix, adding anyhow
as a dependency in Cargo.toml
prevents the compile error.
Otherwise, narrate
is a great library that does exactly what I was looking for!
Format report messages to standard colors.
success!
: greeninfo!
: bluewarning!
: orange4 varients:
varient | output | note |
---|---|---|
success!("hello") |
"success: hello" | |
info!("{}", msg) |
"info: msg string" | |
warning!("title", "hello") |
"title: hello" | 'title' would be orange |
success!("title", "{}", msg") |
"title: msg string" | 'title' would be green |
Basic documentation on all public interfaces
route_cause
to root_cause
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.