{"id":13409820,"url":"https://github.com/i582/cfmt","last_synced_at":"2025-10-08T17:18:36.599Z","repository":{"id":38396038,"uuid":"312676764","full_name":"i582/cfmt","owner":"i582","description":"Small library for simple and convenient formatted stylized output to the console.","archived":false,"fork":false,"pushed_at":"2021-07-01T14:07:37.000Z","size":9632,"stargazers_count":70,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T00:41:26.292Z","etag":null,"topics":["cfmt","color","color-output","format","go","golang","stylized"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i582.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":"2020-11-13T20:29:45.000Z","updated_at":"2025-02-24T23:38:37.000Z","dependencies_parsed_at":"2022-07-18T01:30:46.696Z","dependency_job_id":null,"html_url":"https://github.com/i582/cfmt","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/i582/cfmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i582%2Fcfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i582%2Fcfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i582%2Fcfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i582%2Fcfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i582","download_url":"https://codeload.github.com/i582/cfmt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i582%2Fcfmt/sbom","scorecard":{"id":476317,"data":{"date":"2025-08-11","repo":{"name":"github.com/i582/cfmt","commit":"188d99b014f110b99a503cb2b3e0839d3d7feb95"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/i582/cfmt/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/i582/cfmt/go.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T15:23:43.631Z","repository_id":38396038,"created_at":"2025-08-19T15:23:43.631Z","updated_at":"2025-08-19T15:23:43.631Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278981540,"owners_count":26079644,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cfmt","color","color-output","format","go","golang","stylized"],"created_at":"2024-07-30T20:01:03.528Z","updated_at":"2025-10-08T17:18:36.558Z","avatar_url":"https://github.com/i582.png","language":"Go","readme":"![](doc/logo.png)\n\n[![Build Status](https://travis-ci.org/i582/cfmt.svg?branch=master)](https://travis-ci.org/i582/cfmt) [![Codecov](https://codecov.io/gh/i582/cfmt/branch/master/graph/badge.svg)](https://codecov.io/gh/i582/cfmt) [![Go Report Card](https://goreportcard.com/badge/github.com/i582/cfmt)](https://goreportcard.com/report/github.com/i582/cfmt) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/i582/phpstats/master/LICENSE) ![](https://img.shields.io/badge/-%3C%3E%20with%20%E2%9D%A4-red) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)  \n\n# cfmt\n\n**cfmt** is a small library for **simple and convenient formatted stylized output** to the console, providing an interface that is exactly the same as the standard `fmt` and `log` libraries.\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n  * [Simple usage](#simple-usage)\n  * [Complex style](#complex-style)\n  * [Custom styles](#custom-styles)\n  * [HEX colors](#hex-colors)\n  * [Background color](#background-color)\n* [Other examples](#other-examples)\n* [Supported colors and styles](#supported-colors-and-styles)\n* [Motivation](#motivation)\n* [Contact](#contact)\n* [License](#license)\n\n## Install\n\n```\ngo get -v github.com/i582/cfmt\n```\n\n## Usage\n\nTo switch to `cfmt` anywhere in the code, it is enough to add one letter `c` to `fmt` (or to `log`), import the required part (`cfmt` or `clog`):\n\n```go\nimport (\n\t\"github.com/i582/cfmt/cmd/cfmt\"\n\t// or\n\t\"github.com/i582/cfmt/cmd/clog\"\n)\n```\n\nand you get all the possibilities, the library is fully compatible with the standard libraries `fmt` and `log`\n\n### Simple usage\n\nLet's take an example:\n\nSuppose you need to display text and highlight some word or phrase. Using `cfmt`, all that is needed is to wrap the desired part in `{{}}` and after `::` write the desired styles:\n\n```go\ncfmt.Println(\"This is a {{red color}}::red\")\n```\n\n![](doc/example1.svg)\n\nIf we compare this with the `gookit/color` library, then this example looks more complicated and less readable there:\n\n```go\nfmt.Printf(\"This is a %s\", color.Red.Sprintf(\"red color\"))\n```\n\n### Complex style\n\nIt is even more convenient if you need complex styles, if you want to make the text also bold, then all you need to add is in the format after `|` write `bold`:\n\n```go\ncfmt.Println(\"This is a {{red color}}::red|bold\")\n```\n\n![](doc/example2.svg)\n\nIn `gookit/color`, this is done as follows:\n\n```go\nredBold := color.New(color.FgRed, color.OpBold)\nfmt.Printf(\"This is a %s\", redBold.Sprintf(\"red color\"))\n```\n\n### Custom styles\n\nIn the  `gookit/color` we can reuse the created style, in ` cfmt` this is also possible. To do this, you need to register a new style using the `cfmt.RegisterStyle` function:\n\n```go\ncfmt.RegisterStyle(\"code\", func(s string) string {\n\treturn cfmt.Sprintf(\"{{%s}}::red|underline\", s)\n})\n```\n\nAnd now it can be used anywhere just by writing its name:\n\n```go\ncfmt.Println(\"This is a {{red color}}::code\")\n```\n\n![](doc/example3.svg)\n\nThe new style can of course also be used in conjunction with others:\n\n```go\ncfmt.Println(\"This is a {{red color}}::code|bold\")\n```\n\n![](doc/example4.svg)\n\nAlso you can do whatever you want with the text, which is styled.\n\n```go\ncfmt.RegisterStyle(\"flag\", func(s string) string {\n    return cfmt.Sprintf(\"{{--%s}}::green (-%c)\", s, s[0])\n})\n```\n\n```go\nflag := \"help\"\ncfmt.Println(\"{{%s}}::flag \", flag)\n```\n\n![](doc/example8.svg)\n\n### HEX colors\n\nIf the standard colors are not enough for you, then you can use the colors in the `HEX` format (*NOTE: not all terminals support all colors fully!*).\n\n```go\ncfmt.Println(\"This is a {{red color}}::#ff0000\")\n```\n\n### Background color\n\nTo set the background color, you need to add the prefix `bg` to the color, in the case of standard colors, the first letter of the color must be capitalized:\n\n```go\ncfmt.Println(\"This is a {{red color}}::bgRed\")\n```\n\nFor `HEX` it will look like this:\n\n```go\ncfmt.Println(\"This is a {{red color}}::bg#ff0000\")\n```\n\n## Other examples\n\n```go\ncfmt.RegisterStyle(\"code\", func(s string) string {\n\treturn cfmt.Sprintf(\"{{%s}}::red|underline\", s)\n})\n\ncfmt.Printf(`\n    {{Example of reports}}::bold\n\n    {{                                                                            }}::bgRed\n    {{                            Critical errors found                           }}::bgRed|#ffffff\n    {{                                                                            }}::bgRed\n\n    {{100}}::#ffffff myStyle := color.{{New(color.FgWhite, color.BgBlack, color.OpBold)}}::code|bold\n        {{[100, 17]}}::blue Undefined function New at {{~/projects/test}}::underline:100\n\n    {{101}}::#ffffff {{myStyle}}::code.Print(\"t\")\n        {{[101, 0]}}::blue Undefined variable myStyle at {{~/projects/test}}::underline:101\n`)\n```\n\n![](doc/example6.png)\n\n```go\ncfmt.Print(`\n        {{                 -/+:.          }}::green\n        {{                :++++.          }}::green\n        {{               /+++/.           }}::green\n        {{       .:-::- .+/:-''.::-       }}::green\n        {{    .:/++++++/::::/++++++//:    }}::green\n        {{  .:///////////////////////:    }}::yellow\n        {{  ////////////////////////      }}::yellow\n        {{ -+++++++++++++++++++++++       }}::red\n        {{ /++++++++++++++++++++++/       }}::red\n        {{ /sssssssssssssssssssssss.      }}::red\n        {{ :ssssssssssssssssssssssss-     }}::red\n        {{  osssssssssssssssssssssssso/   }}::magenta\n        {{   syyyyyyyyyyyyyyyyyyyyyyyy+   }}::magenta\n        {{    ossssssssssssssssssssss/    }}::blue\n        {{      :ooooooooooooooooooo+.    }}::blue\n        {{       :+oo+/:-..-:/+o+/-       }}::blue\n`)\n```\n\n![](doc/example7.svg)\n\n## Supported colors and styles\n\n| Styles               |\n| -------------------- |\n| *italic*             |\n| **bold**             |\n| ~~crossout~~         |\n| \u003cins\u003eunderline\u003c/ins\u003e |\n| concealed            |\n| reverse              |\n| blink                |\n\n\n| Colors  |              |               |           |\n| ------- | ------------ | ------------- | --------- |\n| black   | darkGray     | bgDarkGray    | bgBlack   |\n| red     | lightRed     | bgLightRed    | bgRed     |\n| green   | lightGreen   | bgLightGreen  | bgGreen   |\n| yellow  | lightYellow  | bgLightYellow | bgYellow  |\n| blue    | lightBlue    | bgLightBlue   | bgBlue    |\n| magenta | lightMagenta | bgLightMagent | bgMagenta |\n| cyan    | lightCyan    | bgLightCyan   | bgCyan    |\n| white   | lightWhite   | bgLightWhite  | bgWhite   |\n| gray    |              |               | bgGray    |\n\nAnd colors in HEX format. See [HEX colors](#hex-colors) part.\n\n## Motivation\n\nThe existing libraries for styling the output are very powerful and this library builds on one of them ([gookit/color](https://github.com/gookit/color)). However, they are not very useful for styling certain words or sentences, since you need to use `Sprintf` and put the styled ones in a format string, which greatly reduces readability if you need to style many elements.\n\nI believe that the library will be useful primarily for formatting ready-made text, for reference, or examples. However, in other cases, it should be just as convenient.\n\nThe library aims to make formatted text look readable in code, even with complex formatting.\n\n## Contact\n\n For any questions — tg: `@petr_makhnev`.\n\n## License\n\nThis project is under the **MIT License**. See the [LICENSE](https://github.com/i582/phpstats/blob/master/LICENSE) file for the full license text.\n","funding_links":[],"categories":["Command Line","命令行","高级控制台UI","高级控制台UI`用于构建控制台应用程序和控制台用户界面的库.`","Build Automation"],"sub_categories":["Advanced Console UIs","高级控制台用户界面","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi582%2Fcfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi582%2Fcfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi582%2Fcfmt/lists"}