abscissa_core 0.4.0

Application microframework with support for command-line option parsing, configuration, error handling, logging, and terminal interactions. This crate contains the framework's core functionality.
Documentation

Abscissa

Abscissa is a microframework for building Rust applications (either CLI tools or network services), aiming to provide a large number of features with a minimal number of dependencies, and with a strong focus on security.

Features

  • command-line option parsing: simple declarative option parser built on top of the gumdrop crate.
  • configuration: TOML configuration file parsing on application-defined configuration structures which can be dynamically updated at runtime.
  • error handling: generic Error type based on the failure crate, and a unified error-handling subsystem.
  • logging: uses the log crate to provide application-level logging.
  • secrets management: the (optional) secrets module includes a Secret type which derives serde's Deserialize and can be used to represent secret values parsed from configuration files or elsewhere (e.g. credentials loaded from the environment or network requests)
  • terminal interactions: support for colored terminal output (with color support autodetection). Useful for Cargo-like status messages with easy-to-use macros.

Creating a new Abscissa application

The following commands will generate an Abscissa application skeleton:

$ cargo install abscissa
$ abscissa new my_cool_app

The resulting app is a Cargo project. The following files are particularly noteworthy:

  • src/application.rs: Abscissa application type for your app
  • src/commands*: application entrypoint and subcommands. Make sure to check out the hello.rs example of how to make a subcommand.
  • src/config.rs: application configuration
  • src/error.rs: error types

Abscissa applications are implemented as Rust libraries, but have a src/bin subdirectory where the binary entrypoint lives. This means you can run the following within your newly generated application:

$ cargo run -- hello world

This will invoke the hello subcommand of your application (you'll probably want to rename that in a real app) which will print the following:

Hello, world!

You can also run the following to print basic help information:

$ cargo run -- --help

Option Parser

Command-line options are parsed using the gumdrop crate.

Please see the documentation for the options module.

Status Macros

// Print a Cargo-like justified status to STDOUT
status_ok!("Loaded", "app loaded successfully");

// Print an error message
status_err!("something bad happened");

// Print an indented attribute to STDOUT
status_attr_ok!("good", "yep");

// Print an error attribute to STDERR
status_attr_err!("error", "yep");