{"id":22697197,"url":"https://github.com/azur1s/vari","last_synced_at":"2025-07-26T11:13:19.281Z","repository":{"id":57671463,"uuid":"447299880","full_name":"azur1s/vari","owner":"azur1s","description":"Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal.","archived":false,"fork":false,"pushed_at":"2022-01-15T19:03:28.000Z","size":170,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T04:46:08.878Z","etag":null,"topics":["ansi","cli","color","colors","cosmetics","formatter","rust","style","terminal"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azur1s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-12T16:56:44.000Z","updated_at":"2022-11-02T16:14:44.000Z","dependencies_parsed_at":"2022-09-14T09:21:47.382Z","dependency_job_id":null,"html_url":"https://github.com/azur1s/vari","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azur1s%2Fvari","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azur1s%2Fvari/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azur1s%2Fvari/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azur1s%2Fvari/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azur1s","download_url":"https://codeload.github.com/azur1s/vari/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665779,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","cli","color","colors","cosmetics","formatter","rust","style","terminal"],"created_at":"2024-12-10T05:12:25.391Z","updated_at":"2025-04-13T04:46:17.771Z","avatar_url":"https://github.com/azur1s.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/azur1s/vari/master/assets/vari_logo.png)\n# Vari\n[![crates.io](https://img.shields.io/crates/v/vari.svg)](https://crates.io/crates/vari)\n[![crates.io](https://docs.rs/chumsky/badge.svg)](https://docs.rs/vari/)\n[![crates.io](https://img.shields.io/crates/dr/vari)](https://crates.io/crates/vari)\n[![License](https://img.shields.io/crates/l/vari.svg)](https://github.com/azur1s/vari#license)\n\nVari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal. Like [Rich](https://github.com/Textualize/rich) library for Python.\n\u003e Väri means \"color\" in Finnish.\n\n## Installing\nVari come with color anchors as default feature,\nThe other opt-in features are: \"log\", \"fun\",\n```toml\n[dependencies]\nvari =  \"0.2.1\"\n```\n\n## Features\n\n### Color Anchor\n\u003e This is in default features.\n\nColor anchor are a bbcode-like markup for colors and styles (eg. \"[\\$red]\", \"[bg\\$yellow]\", \"[\\$bold]\")\n\n\u003cdetails\u003e\n\u003csummary\u003eAnchors\u003c/summary\u003e\n\u003cp\u003eColors:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003e[$black]\u003c/li\u003e\n    \u003cli\u003e[$red]\u003c/li\u003e\n    \u003cli\u003e[$green]\u003c/li\u003e\n    \u003cli\u003e[$yellow]\u003c/li\u003e\n    \u003cli\u003e[$blue]\u003c/li\u003e\n    \u003cli\u003e[$magenta]\u003c/li\u003e\n    \u003cli\u003e[$cyan]\u003c/li\u003e\n    \u003cli\u003e[$white]\u003c/li\u003e\n    \u003cli\u003e[$reset] or [$r] or [$/]\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eBright colors:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003e[$bright_black] or [$brightblack]\u003c/li\u003e\n    \u003cli\u003e[$bright_red] or [$brightred]\u003c/li\u003e\n    \u003cli\u003e[$bright_green] or [$brightgreen]\u003c/li\u003e\n    \u003cli\u003e[$bright_yellow] or [$brightyellow]\u003c/li\u003e\n    \u003cli\u003e[$bright_blue] or [$brightblue]\u003c/li\u003e\n    \u003cli\u003e[$bright_magenta] or [$brightmagenta]\u003c/li\u003e\n    \u003cli\u003e[$bright_cyan] or [$brightcyan]\u003c/li\u003e\n    \u003cli\u003e[$bright_white] or [$brightwhite]\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eStyles\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003e[$regular]\u003c/li\u003e\n    \u003cli\u003e[$bold]\u003c/li\u003e\n    \u003cli\u003e[$dim] or [$low] or [$low_intensity] or [$lowintensity]\u003c/li\u003e\n    \u003cli\u003e[$italic]\u003c/li\u003e\n    \u003cli\u003e[$underline]\u003c/li\u003e\n    \u003cli\u003e[$blink] or [$blinking]\u003c/li\u003e\n    \u003cli\u003e[$reverse] or [$reversed]\u003c/li\u003e\n    \u003cli\u003e[$invisible] or [$hidden]\u003c/li\u003e\n    \u003cli\u003e[$strikethrough] or [$strike_through]\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eNote: [bg$any] is a valid anchors, it will be translated to [$reversed][$any] (where `any` is the color/style name above)\u003c/p\u003e\n\u003c/details\u003e\n\n```rust\n// [$/] is shorthand for [$reset]\nlet message = vari::format(\"[$blue]Hello, [$green]World![$/]\");\nprintln!(\"{}\", message);\n\n// Custom RGB!\nprintln!(\"{}\", vari::format(\"[$[114, 119, 39]]#727727![$[66, 4, 32]] Do you see it?[$/]\"));\n\n// Style anchor and also easy macros :O\nvprintln!(\"{}Bold and Italic :O{}\", \"[$bold][$italic]\", \"[$/]\");\n\n// Background color\nvprintln!(\"{}Backgroundssss{}[$/]\", \"[bg$magenta]\", \"[bg$[188, 188, 188]]World![$/]\")\n\n// Hexadecimal\nvprintln!(\"[$#ffffff]Hello, [$#000000]World![$/]\");\n```\n\n### Colorize\n```toml\n[dependencies]\nvari = { version =  \"0.2.1\", features = [\"colorize\"] }\n```\n\nColorize string directly by calling colorize() method, like [colored](https://github.com/mackwic/colored) crate.\n\nFor example: \"red\".colorize(\"red\") is the same as \"[\\$red]red[$/]\"\n\nNote: Chaining is not yet implemented, because .colorize() adds [$/] so you can't chain styles\n\nThe argument should be the color's name (the same name as the anchor colors).\n```rust\nuse vari::colorize::Colorize;\n\nfn main() {\n    println!(\"{}\", \"Hello, World\".colorize(\"cyan\"));\n    println!(\"{}\", \"This is red\".colorize(\"brightred\"));\n    println!(\"{}\", \"Bold.\".colorize(\"bold\"));\n}\n```\n\n### Log\n```toml\n[dependencies]\nvari = { version =  \"0.2.1\", features = [\"log\"] }\n```\n\nSome println-ish function for logging\n\n```rust\nlet log_message = vformat!(\"[$green]This message is send by main.rs![$/]\");\nlet log_file = vformat!(\"[$dim]src/main.rs[$/]\");\nvari::util::log(\u0026log_message, \u0026log_file);\n```\n![logs](https://raw.githubusercontent.com/azur1s/vari/master/assets/log.png)\n\n### No ANSI for .len()\n\u003e This is in default features.\n\nThis might be used in padding calculation, because in colored string (eg. \"\\x1b[31mTest\\x1b[0m\"),\nthe length calculated also contains the \"[31m\" and the \"[0m\" in it, making the padding incorrect.\nSo this trait implements a \".no_ansi()\" which remove all the ANSI escape sequence and then you could do\n\".len()\" after it.\n```rust\n// vari::util::log()\n\n// Calculate padding amount between the message.\n// eg. left________right\nlet padding_amount = w - right.no_ansi().len() - left.no_ansi().len();\nlet padding = \" \".repeat(padding_amount);\n        \nlet mut result = String::new();\n\nresult.push_str(left);\nresult.push_str(\u0026padding);\nresult.push_str(right);\n\nreturn result      \n```\n![no_ansi()](https://raw.githubusercontent.com/azur1s/vari/master/assets/no_ansi.png)\n\n### Fun\n```toml\n[dependencies]\nvari = { version =  \"0.2.1\", features = [\"fun\"] }\n```\n\n```rust\nfn main() {\n    // Rainbow colors!\n    println!(\"{}\", vari::fun::rainbow(\"Rainbow!!!\"));\n}\n```\n## License\nThis crate is under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.en.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazur1s%2Fvari","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazur1s%2Fvari","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazur1s%2Fvari/lists"}