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 essentially wraps a user defined function with automatic configuration/setup/processing of:
- logging (via
tracing) - command-line arguments (via
clap) .dotenvfile(s), environment variable population/overrides (viadotenvy)- easy application error handling (via
anyhow)
The user defined function is intended to be/replace main().
Thus, the main/entrypoint function can be written as if all the configuration/processing/boilerplate is ready-to-use. More explicitly:
clap::Parserstruct has been parsed & populated.dotenvfiles have been parsed; environment variables are ready to gotracinghas been configured & the global subscriber has been registered
Using the default behavior is totally reasonable, but overwriting some traits' default impl(s) can provide customization.
Usage
-
Include the
entrypointprelude:use *; -
Define a
clapstruct: -
Define an entrypoint/main function:
This function must:
- accept a
clap::Parseras an input - return
entrypoint::anyhow::Result<()>
- accept a
Note: #[entrypoint::entrypoint] should be first when used with other attribute macros.
e.g.:
async
For more information, refer to:
Crates
entrypoint is divided into the following crates:
entrypoint: core traits & functionalityentrypoint_macros: convienence macros to further reduce boilerplate
Contributing
Before doing anything else: open an issue.