██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗
██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝
██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗
██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║ ╦═╗ ╦ ╦ ╔═╗ ╔╦╗
╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║ ╠╦╝ ║ ║ ╚═╗ ║
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╩╚═ ╚═╝ ╚═╝ ╩
This is a silly little command line tool for sexy ANSI fonts in the console. Give your cli some love.
Read the docs over at docs.rs.
Installing
Arch Linus User repository
sudo pacman -S cfonts
MacPorts
sudo port install cfonts
cargo
cargo install cfonts
To use it in your shell:
$ cfonts "Hello|World\!"
💡 Remember to escape the !
character with \
in most shells
Or use it in your project:
[dependencies]
cfonts = "1"
extern crate cfonts;
use cfonts::{ say, Options, Align, BgColors, Colors, Env, Fonts, Rgb };
fn main() {
say(Options {
text: String::from("Hi there"),
font: Fonts::FontBlock,
colors: vec![Colors::System],
background: BgColors::Transparent,
align: Align::Left,
letter_spacing: 1,
line_height: 1,
spaceless: false,
max_length: 0,
gradient: Vec::new(),
independent_gradient: false,
transition_gradient: false,
env: Env::Cli,
..Options::default()
});
}
All settings are optional and shown here with their default
You can use cfonts
in your project without the direct output to the console:
extern crate cfonts;
use cfonts::{ render, Options, Fonts };
fn main() {
let output = render(Options {
text: String::from("hello"),
font: Fonts::FontTiny,
..Options::default()
});
assert_eq!(
output.text,
format!("{}{}{}",
"\n\n",
" █ █ █▀▀ █ █ █▀█\n",
" █▀█ ██▄ █▄▄ █▄▄ █▄█\n\n"
)
);
assert_eq!(output.vec, vec![
String::from("\n\n █ █ █▀▀ █ █ █▀█"),
String::from( " █▀█ ██▄ █▄▄ █▄▄ █▄█"),
String::from("\n"),
]);
assert_eq!(output.lines, 1);
assert_eq!(output.options, Options {
text: String::from("hello"),
font: Fonts::FontTiny,
..Options::default()
});
}
CLI Usage
Read more in the root repo.
Tests
All tests are run via for the below platforms with our CI.
Platform |
---|
Linux |
OSX |
Windows |
Unit tests
There are some unit tests and some integration tests within the ./tests
folder.
We also have an end-to-end test script!!missing!! setup that runs on the binaries (on all platforms) and compares its output against fixtures and the output of the node implementation.
Release History
- 1.0.4 - Fixed NO_COLOR not being respected in help, fixed color conversion rgb to ansi_256
- 1.0.3 - Fixed NO_COLOR support when run without FORCE_COLOR
- 1.0.2 - Fixed help and version flags in first position
- 1.0.1 - Fixed font loading
- 1.0.0 - Public release of rust API
- 0.1.0 - alpha test
License
Copyright (c) 2022 Dominik Wilkowski. Licensed under the GNU GPL-3.0-or-later.