{"id":28540657,"url":"https://github.com/leecade/sty","last_synced_at":"2025-07-18T16:05:40.847Z","repository":{"id":228653853,"uuid":"774575150","full_name":"leecade/sty","owner":"leecade","description":"Style terminal outputs in a minimal, macro-based, and dead simple way.","archived":false,"fork":false,"pushed_at":"2024-03-21T09:04:47.000Z","size":20,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-07T11:41:29.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leecade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-19T19:40:52.000Z","updated_at":"2025-01-07T22:16:41.000Z","dependencies_parsed_at":"2024-03-19T21:06:38.696Z","dependency_job_id":"a165d87d-44f6-4ce9-beea-59853384aeed","html_url":"https://github.com/leecade/sty","commit_stats":null,"previous_names":["leecade/sty"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/leecade/sty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leecade%2Fsty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leecade%2Fsty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leecade%2Fsty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leecade%2Fsty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leecade","download_url":"https://codeload.github.com/leecade/sty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leecade%2Fsty/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264861169,"owners_count":23674699,"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":[],"created_at":"2025-06-09T19:36:57.937Z","updated_at":"2025-07-18T16:05:40.823Z","avatar_url":"https://github.com/leecade.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sty 🌈\n\n[![Crates.io](https://img.shields.io/crates/v/sty.svg)](https://crates.io/crates/sty)\n[![docs-rs](https://docs.rs/sty/badge.svg)](https://docs.rs/sty)\n![Downloads](https://img.shields.io/crates/d/sty)\n\n## $\\mathbb{\\color{red}{Style \\ } \\color{lightblue}{terminal}\\ \\color{black}{outputs \\ }\\color{gray}{\\ in\\ a} \\color{magenta}{\\ minimal}\\color{gray}{,} \\color{lightyellow}{\\ macro\\ based}\\color{gray}{,}\\ and \\color{lightgreen}{\\ dead\\ simple} \\color{gray}{\\ way.}}$\n\n|                               |   Code    |  Backgroud   |      Bright      |  Bright background  |\n| ----------------------------- | :-------: | :----------: | :--------------: | :-----------------: |\n| $\\mathbb{\\color{black}{■}}$   |  `black`  |  `bg_black`  |                  |                     |\n| $\\mathbb{\\color{gray}{■}}$    |  `gray`   |  `bg_gray`   |                  |                     |\n| $\\mathbb{\\color{white}{■}}$   |  `white`  |  `bg_white`  |  `white_bright`  |  `bg_white_bright`  |\n| $\\mathbb{\\color{red}{■}}$     |   `red`   |   `bg_red`   |   `red_bright`   |   `bg_red_bright`   |\n| $\\mathbb{\\color{green}{■}}$   |  `green`  |  `bg_green`  |  `green_bright`  |  `bg_green_bright`  |\n| $\\mathbb{\\color{yellow}{■}}$  | `yellow`  | `bg_yellow`  |  `yello_bright`  | `bg_yellow_bright`  |\n| $\\mathbb{\\color{blue}{■}}$    |  `blue`   |  `bg_blue`   |  `blue_bright`   |  `bg_blue_bright`   |\n| $\\mathbb{\\color{magenta}{■}}$ | `magenta` | `bg_magenta` | `magenta_bright` | `bg_magenta_bright` |\n| $\\mathbb{\\color{cyan}{■}}$    |  `cyan`   |  `bg_cyan`   |  `cyan_bright`   |  `bg_cyan_bright`   |\n\n\u003e **`bold`** _`italic`_ \u003cins\u003e`underline`\u003c/ins\u003e \u003cs\u003e`strikethrough`\u003c/s\u003e `overline` `dim` `inverse` `hidden` `reset`\n\n## Highlights\n\n- **Macro-based**: Increases compile-time efficiency and boosts safety.\n- **Innovative Styling**: Compose styles in an array-like format such as `[red, bold, underline]`.\n- **Extensive Type Support**: All types implementing `std::fmt::Display` trait are supported, offering wide-ranging adaptability.\n- **Full Color and Style support**: Modifiers / Foreground colors / Background colors / Bright foreground colors / Bright background colors.\n- **Zero dependencies**: Cleaner code-base with no third-party interference.\n- **Supports `tty` detection**: Avoids styling when the tty lacks color support, Use `set_color_enabled` for manual enable control.\n\n## Documentation\n\n[![docs-rs](https://docs.rs/sty/badge.svg)](https://docs.rs/sty)\n\n## Installation\n\nThis crate works with Cargo. Add the following to your Cargo.toml dependencies section:\n\n```toml\n[dependencies]\nsty = \"0.3\"\n```\n\n## Basic usage\n\n```rust\nuse sty::{\n    sty,\n    style::{red, underline},\n};\n// or\n// use sty::{ sty, red, underline };\n\nprintln!(\"{}\", sty!(\"Hello world!\", [red]));\n\n// Use `sty!` macro for combination of multiple styles\nprintln!(\"{}\", sty!(\"Hello world!\", [red, underline]));\n\n// Use `sty!` macro for multiple input types\nprintln!(\"{}\", sty!(123, [red, underline]));\n\n// Use style function is simple for `\u0026str` input\nprintln!(\"{}\", red(\"Hello world!\"));\nprintln!(\"{}\", underline(\u0026red(\"Hello world!\")));\n```\n\n\u003e [!TIP]\n\u003e In style combinations, the styles that are specified later take precedence, For example:\n\n```rust\nuse sty::{ sty, style::* };\nsty!(\"str\", [red, green, blue]); // blue\nsty!(\"str\", [red, underline, reset]); // reset\n```\n\n\u003e [!TIP]\n\u003e If `tty` environment does not support color, default output will be printed without any styling, Use `set_color_enabled` for manual enable control, For example:\n\n```rust\nuse sty::{ set_color_enabled, is_color_enabled, sty, style::* };\nlet enabled = is_color_enabled();\nset_color_enabled(false);\nsty!(\"123\", [red]); // no color\nset_color_enabled(true);\nsty!(\"123\", [red]); // red\nset_color_enabled(enabled);\n```\n\n### `sty!` Macro\n\nThe `sty!` macro is a powerful utility conveniently used to apply a collection of style manipulations to your input. This macro allows you to seamlessly incorporate text properties with an intuitive syntax.\n\n```rust\nuse sty::{ sty, style::{red, underline} };\nprintln!(\"{}\", sty!(\"Hello world!\", [red, underline]));\n```\n\nIn this example, `red` and `underline` are both style transformations, and the sty! macro returns a newly styled text instance with all these styling elements applied. Multiple styles can be applied simultaneously, and the output will be a combination of all.\n\n#### Supported input types\n\nFor any type that has implemented the `std::fmt::Display` trait, like:\n\n- `\u0026str`\n- `String`\n- `numbers`(`usize`, `i8`, `i16`, `i32`, `i64`, `i128`, `u8`, `u16`, `u32`, `u64`, `u128`, `f32`, `f64`)\n- `bool`\n- ...\n\n### Style function\n\nEach style function can be combine with `sty!` macro or used separately, for example:\n\n```rust\nuse sty::{\n    sty,\n    style::{red, underline},\n};\n// or\n// use sty::{ sty, red, underline };\n\nsty!(\"Hello world!\", [red, underline]);\n// or\nred(\"Hello world!\");\n```\n\n\u003e [!TIP]\n\u003e The standalone style function only supports `\u0026str` input type.\n\nAll style functions are as follows:\n\n- Modifiers\n  - `reset`\n  - `bold`\n  - `dim`\n  - `italic`\n  - `underline`\n  - `overline`\n  - `inverse`\n  - `hidden`\n  - `strikethrough`\n- Foreground colors\n  - `black`\n  - `red`\n  - `green`\n  - `yellow`\n  - `blue`\n  - `magenta`\n  - `cyan`\n  - `white`\n  - `gray`\n- Background colors\n  - `bg_black`\n  - `bg_red`\n  - `bg_green`\n  - `bg_yellow`\n  - `bg_blue`\n  - `bg_magenta`\n  - `bg_cyan`\n  - `bg_white`\n  - `bg_gray`\n- Bright foreground colors\n  - `red_bright`\n  - `green_bright`\n  - `yellow_bright`\n  - `blue_bright`\n  - `magenta_bright`\n  - `cyan_bright`\n  - `white_bright`\n- Bright background colors\n\n  - `bg_red_bright`\n  - `bg_green_bright`\n  - `bg_yellow_bright`\n  - `bg_blue_bright`\n  - `bg_magenta_bright`\n  - `bg_cyan_bright`\n  - `bg_white_bright`\n\n## Contribution\n\n[CONTRIBUTING](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleecade%2Fsty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleecade%2Fsty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleecade%2Fsty/lists"}