entrypoint
eliminate main function boilerplate with this opinionated application framework/wrapper
About
entrypoint has the following design goals:
- eliminate application startup/configuration boilerplate
- help enforce application best practices
What does this crate actually do?
entrypoint wraps a user defined function with automatic configuration/setup/processing of:
- easy application error handling (via
anyhow) - command-line argument parsing (via
clap) .dotenvfile processing and environment variable population/overrides (viadotenvy)- logging (via
tracing)
The user defined function is intended to be/replace main().
Meaning, this main/entrypoint function can be written as if all the configuration/processing/boilerplate is ready-to-use. More explicitly:
anyhowis available and ready to useclap::Parserstruct has been parsed and populated.dotenvfiles have been parsed; environment variables are ready to gotracinghas been configured and the global subscriber has been registered
A note from the developer
entrypoint was as much about deploying my first crate as anything else.
Turns out, it's really not that useful. I kind of think it's better just to explicitly set this stuff up in your application. The juice isn't work the squeeze.
It's unlikely further development will occur.
Usage
Default Config
-
Include the
entrypointprelude:use *; -
Define a
clapstruct and derive default entrypoint trait impls: -
Define an entrypoint/main function:
Custom Config
Using the default behavior is totally reasonable, but overwriting some default impl(s) can provide customization.
Usage Notes
- The
entrypointfunction must:- Have a
clap::Parserinput parameter - return
entrypoint::anyhow::Result<()>
- Have a
#[entrypoint::entrypoint]ordering may matter when used with other attribute macros (e.g.[tokio::main]).
Documentation
For more information, refer to:
Crates
entrypoint is divided into the following crates:
entrypoint: core traits and functionalityentrypoint_macros: convienence macros to further reduce boilerplate
Contributing
Before doing anything else: open an issue.