Projects STRLCPY cfonts Files
🤬
..
src Loading last commit info...
tests
Cargo.lock
Cargo.toml
Makefile
README.md
config.toml
rustfmt.toml
README.md
     ██████╗ ███████╗  ██████╗  ███╗   ██╗ ████████╗ ███████╗
    ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗  ██║ ╚══██╔══╝ ██╔════╝
    ██║      █████╗   ██║   ██║ ██╔██╗ ██║    ██║    ███████╗
    ██║      ██╔══╝   ██║   ██║ ██║╚██╗██║    ██║    ╚════██║    ╦═╗ ╦ ╦ ╔═╗ ╔╦╗
    ╚██████╗ ██║      ╚██████╔╝ ██║ ╚████║    ██║    ███████║    ╠╦╝ ║ ║ ╚═╗  ║
     ╚═════╝ ╚═╝       ╚═════╝  ╚═╝  ╚═══╝    ╚═╝    ╚══════╝    ╩╚═ ╚═╝ ╚═╝  ╩

cfont styles!!missing!!

api example!!missing!!

crates badge crates docs tests build status

This is a silly little command line tool for sexy fonts in the console. Give your cli some love.

Read the docs over at docs.rs.

Installing

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 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.0 - Public release of rust API
  • 0.1.0 - alpha test

License

Copyright (c) 2022 Dominik Wilkowski. Licensed under the GNU GPLv3.

Please wait...
Page is in error, reload to recover