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,warnanderrormessages - Convenient traits and methods for printing color escape codes when available
- Print
Lists andTrees - Simplify dealing with terminal colors using color
Palettes - Request and validate user input
- Launch
$EDITORto edit plain text and typed data - Animated spinners (using
tokioforasyncprojects andstd::threadotherwise)
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
- Multi-line text segments like
Lists orTrees - spin
Spinneranimations- style
- Color
PaletteandTags - term
- Writing colored text to the terminal
Macros§
- edit_
as_ toml - Implement
Editablefor a typeT: Serialize + DeserializeOwned - inline
- Concatenate
Pushabletypes to becomeInlineas one
Structs§
- Claw
- The main
Conciliatorimplementor - Tag
- Wraps a
strto beInlined as a colored[ tag ]
Enums§
- Wrap
- Wraps any
Displaytype to beInlined with the chosenColor - Wrap
Bold - Wraps any
Displaytype to beInlined with the chosenColorbut in bold
Traits§
- Conciliator
[ > ]Decorate user-facing messages with tags- Inline
Displaywith colors- Pushable
- Types that are
InlineorDisplay
Functions§
- init
- Initialize the main
Conciliatorimplementor,Claw