13 releases
0.3.10 | Aug 25, 2024 |
---|---|
0.3.9 | Mar 3, 2024 |
0.3.8 | Dec 2, 2023 |
0.3.7 | Jul 29, 2023 |
0.3.3 | Jul 30, 2022 |
#221 in Command-line interface
Used in 2 crates
200KB
4K
SLoC
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.
Dependencies
~3–13MB
~170K SLoC