{"id":13409897,"url":"https://github.com/workanator/go-ataman","last_synced_at":"2026-02-03T14:36:47.173Z","repository":{"id":55538432,"uuid":"91610983","full_name":"workanator/go-ataman","owner":"workanator","description":"Another Text Attribute Manupulator","archived":false,"fork":false,"pushed_at":"2020-12-23T05:36:05.000Z","size":45,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-25T04:09:42.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/workanator.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":"2017-05-17T19:04:57.000Z","updated_at":"2024-09-02T04:28:14.000Z","dependencies_parsed_at":"2022-08-15T02:50:25.819Z","dependency_job_id":null,"html_url":"https://github.com/workanator/go-ataman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/workanator/go-ataman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workanator%2Fgo-ataman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workanator%2Fgo-ataman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workanator%2Fgo-ataman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workanator%2Fgo-ataman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/workanator","download_url":"https://codeload.github.com/workanator/go-ataman/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workanator%2Fgo-ataman/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29047566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-07-30T20:01:03.938Z","updated_at":"2026-02-03T14:36:47.102Z","avatar_url":"https://github.com/workanator.png","language":"Go","funding_links":[],"categories":["命令行","Command Line","Build Automation","\u003cspan id=\"命令行-command-line\"\u003e命令行 Command Line\u003c/span\u003e","高级控制台UI","高级控制台UI`用于构建控制台应用程序和控制台用户界面的库.`"],"sub_categories":["高级控制台用户界面","Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI"],"readme":"![Gopher Ataman](https://github.com/workanator/repo-faces/blob/main/go-ataman/main.png)\n\n# go-ataman\n**Another Text Attribute Manipulator**\n\n[![GoDoc](https://godoc.org/gopkg.in/workanator/go-ataman.v1?status.svg)](https://godoc.org/gopkg.in/workanator/go-ataman.v1)\n[![Build Status](https://travis-ci.org/workanator/go-ataman.svg?branch=master)](https://travis-ci.org/workanator/go-ataman)\n[![Coverage Status](https://coveralls.io/repos/github/workanator/go-ataman/badge.svg?branch=master)](https://coveralls.io/github/workanator/go-ataman?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/workanator/go-ataman)](https://goreportcard.com/report/github.com/workanator/go-ataman)\n[![License](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/workanator/go-ataman/blob/master/LICENSE)\n\nThe goal of the project is to help render colored text in terminal applications\nwith text attribute manipulation contained in text template.\nThe idea is similar to HTML, e.g. `\u003cspan style=\"color:green\"\u003eHello!\u003c/span\u003e`\n\n**ataman** is not a full-featured template processor. It aims only on simple\nterminal text attribute, graphic mode in ANSI terms, manipulations using\nANSI sequences.\n\n## Features\n\n- Parsing and rendering template with single iteration.\n- Minimal memory allocations with pooling.\n- Thread-safe parsing and rendering.\n- Fully customizable decoration of tags.\n\n## Installation\n\nTo install the package use `go get gopkg.in/workanator/go-ataman.v1`\n\n## Quick Example\n\nThe next example shows basic usage of the package. The renderer here uses\nbasic decoration style.\n\n```go\nrndr := ataman.NewRenderer(ataman.BasicStyle())\ntpl := \"\u003clight+green\u003e%s\u003c-\u003e, \u003cbg+light+yellow,black,bold\u003e \u003c\u003c%s\u003e\u003e \u003c-\u003e\u003cred\u003e!\"\nfmt.Println(rndr.MustRenderf(tpl, \"Hello\", \"Terminal World\"))\n\n```\n\nThis example produces colored text like this.\n\n![Example Output](https://github.com/workanator/repo-faces/blob/main/go-ataman/example1.png)\n\nRenderer is able to pre-render templates so in further output operations they\ncan be reused without parsing and rendering. In this example the renderer uses\ncurly brackets decoration style.\n\n```go\nrndr := ataman.NewRenderer(ataman.CurlyStyle())\nprep := rndr.MustPrepare(\"{light_green}%s{-}, {bg_light_yellow+black+bold} \u003c%s\u003e {-}{red}!\")\nfmt.Println(rndr.MustRenderf(tpl, \"Hi\", \"Everybody\"))\n```\n\nThe pre-rendered template implements `fmt.Stringer` interface so it can be used\nin output operations without additional code, e.g.\n\n```go\nprep := rndr.MustPrepare(\"{red}Red {green}Green {blue}Blue{-}\")\nfmt.Println(prep)\n```\n\n## Writing Templates\n\nTemplates follow the simple rules.\n\n- Tag can contain one or more attributes, e.g. `{white,bold}`, `{red}`.\n- If template should render open or close tag sequence as regular text then\n  the sequence should be doubled. For example, if tag is enclosed in `{` and `}`\n  then in template it should be `This rendered as {{regular text}}`.\n- Renderer adds reset graphic mode ANSI sequence to the each template if it\n  contains any other ANSI sequences. So visually those templates are equivalent\n  `{bold}Bold{-}` and `{bold}Bold`.\n\nDecoration styles use the follows dictionary.\n\n* `-` or `reset` stand for reset graphic mode.\n* `b` or `bold` make font bold.\n* `u` or `underscore` or `underline` make font underline.\n* `blink` makes font blink.\n* `reverse` swaps text and background colors.\n* `conceal` makes font concealed (whatever that means).\n* `black` color.\n* `red` color.\n* `green` color.\n* `yellow` color.\n* `blue` color.\n* `magenta` color.\n* `cyan` color.\n* `white` color.\n* `default` reverts to the default color.\n* `bg` or `background` should be used in conjunction with color to set\n  background color.\n* `intensive` or `light` should be used in conjunction with color to make\n  the color intensive. Could be used with `background` as well.\n\nSome template examples with curly decoration style.\n\n- `{light_green}` - makes text light (intensive) green.\n- `{bg_yellow}` - makes background yellow.\n- `{bold}` - makes font bold.\n- `{red,bg_blue}` - makes text red on blue background.\n- `{u,black,bg_intensive_white}` - makes text black with underline font on\n  intensive white background.\n- `{-}` - reset the current graphic mode.\n\n## Customizing Renderer\n\nThe package allows to customize tag decorations what can be achieved through\n`decorate.Style` struct. The struct should be initialized with preferred\nvalues. For example with the code below we can define a decoration style\nlike `[[bold,yellow]]Warning![[-]] [[intensive_white]]This package is awesome![[-]] :)`.\n\n```go\nstyle := decorate.Style{\n  TagOpen:            decorate.NewMarker(\"[[\"),\n  TagClose:           decorate.NewMarker(\"]]\"),\n  AttributeDelimiter: decorate.NewMarker(\",\"),\n  ModDelimiter:       decorate.NewMarker(\"-\"),\n  Attributes:         ansi.DefaultDict,\n}\n\nrndr := ataman.NewRenderer(style)\n```\n\nThe rules of decoration styles are the follows.\n\n- `TagOpen` is the sequence of runes which open tag.\n- `TagClose` is the sequence of runes which close tag.\n- `AttributeDelimiter` is the sequence of runes which delimits attributes\n  inside tag.\n- `ModDelimiter` is the sequence of runes which delimits modifiers\n  in attribute.\n- `Attributes` is the map of attributes, where key is the name of ANSI code\n  user uses in templates and value is the ANSI code used in ANSI sequence.\n\nIt's recommended to use attribute codes defined in `ansi` package with the\ndefault Renderer provided by **ataman**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkanator%2Fgo-ataman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkanator%2Fgo-ataman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkanator%2Fgo-ataman/lists"}