Crate conciliator

Source
Expand description

WIP library for writing interactive CLI programs.

Currently very unstable with a somewhat unusual API. Subject to major changes as I use it and implement missing functionality. Intended to implement the things that the Python click library provides which are missing from clap. Using that basis, provide useful abstractions for interacting with the CLI.

Features:

Out of scope:

  • Non-UNIX platforms
  • Config file handling
  • Argument parsing (intended to be used alongside clap)
  • Progress bars (for now)
  • curses-style text user interface (TUI) painting to the terminal as a canvas

Initially, this library was written as an extension of termcolor, but now the functionality that was required has been absorbed / copied / rewritten. As such, some of the ideas and design are taken from there and credit is due.

§Capture output during cargo test

As explained in core::Stream, there is an issue with cargo test only capturing output that uses the print!, println!, eprint!, and eprintln! macros (see rust#12309 and rust#90785).
As a workaround, this crate provides the test_capture feature flag which makes all output go through those macros. This is worse (see core::Stream on how), but it also makes cargo test properly capture the output.

Luckily, there is a way to have this feature only enabled when it is needed: simply add this crate as a development dependency as well, with the test_capture feature enabled only on that entry and not on the regular dependency, like so:

[dependencies]
conciliator = "…"

[dev-dependencies.conciliator]
version = "…"
features = ["test_capture"]

This way, the test_capture feature will only be enabled for compiling “tests, examples, and benchmarks” (see cargo reference) and not for building binaries.

Re-exports§

pub use crate::core::Buffer;
pub use crate::core::Line;
pub use crate::core::Stream;
pub use crate::core::GetLine;
pub use input::Input;
pub use spin::Spinner;
pub use print::Print;
pub use print::List;
pub use print::Tree;
pub use style::Paint;
pub use style::Palette;
pub use style::Color;
pub use style::Tags;

Modules§

core
Core functionality: dealing with buffers of colored terminal output
edit
Edit text using $EDITOR
input
User input
print
Multi-line text segments like Lists or Trees
spin
Spinner animations
style
Color Palette and Tags
term
Writing colored text to the terminal

Macros§

edit_as_toml
Implement Editable for a type T: Serialize + DeserializeOwned
inline
Concatenate Pushable types to become Inline as one

Structs§

Claw
The main Conciliator implementor
Tag
Wraps a str to be Inlined as a colored [ tag ]

Enums§

Wrap
Wraps any Display type to be Inlined with the chosen Color
WrapBold
Wraps any Display type to be Inlined with the chosen Color but in bold

Traits§

Conciliator
[ > ] Decorate user-facing messages with tags
Inline
Display with colors
Pushable
Types that are Inline or Display

Functions§

init
Initialize the main Conciliator implementor, Claw