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:
- Pretty
status
,info
,warn
anderror
messages - Convenient traits and methods for printing color escape codes when available
- Print
List
s andTree
s - Simplify dealing with terminal colors using color
Palette
s - Request and validate user input
- Launch
$EDITOR
to edit plain text and typed data - Animated spinners (using
tokio
forasync
projects andstd::thread
otherwise)
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 functionality: dealing with buffers of colored terminal output
- Edit text using
$EDITOR
- User input
Spinner
animations- Writing colored text to the terminal
Macros§
- Implement
Editable
for a typeT: Serialize + DeserializeOwned
Structs§
- The main
Conciliator
implementor
Enums§
Traits§
[ > ]
Decorate user-facing messages with tagsDisplay
with colors
Functions§
- Initialize the main
Conciliator
implementor,Claw