{"id":22509192,"url":"https://github.com/adrg/splash","last_synced_at":"2025-07-05T00:41:24.838Z","repository":{"id":19357698,"uuid":"22597355","full_name":"adrg/splash","owner":"adrg","description":"Splash is a small package which allows styling terminal output","archived":false,"fork":false,"pushed_at":"2021-10-31T07:36:22.000Z","size":24,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-21T02:13:42.352Z","etag":null,"topics":["background-color","color","colors","console","go","golang","library","package","shell","splash","terminal","text-color"],"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/adrg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-04T08:38:03.000Z","updated_at":"2023-08-27T13:26:19.000Z","dependencies_parsed_at":"2022-09-13T10:40:14.560Z","dependency_job_id":null,"html_url":"https://github.com/adrg/splash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrg%2Fsplash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrg%2Fsplash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrg%2Fsplash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrg%2Fsplash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrg","download_url":"https://codeload.github.com/adrg/splash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228547956,"owners_count":17935152,"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":["background-color","color","colors","console","go","golang","library","package","shell","splash","terminal","text-color"],"created_at":"2024-12-07T01:28:04.050Z","updated_at":"2024-12-07T01:28:04.611Z","avatar_url":"https://github.com/adrg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/adrg/adrg.github.io/master/assets/projects/splash/logo.png\" alt=\"splash logo\" /\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/adrg/splash\"\u003e\n        \u003cimg alt=\"pkg.go.dev documentation\" src=\"https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"\u003e\n        \u003cimg alt=\"MIT license\" src=\"https://img.shields.io/github/license/adrg/splash\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/adrg/splash\"\u003e\n        \u003cimg alt=\"Go report card\" src=\"https://goreportcard.com/badge/github.com/adrg/splash\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nSplash is a small package which allows styling terminal output.\nIt provides a set of types and functions to facilitate coloring and styling of\noutput text. It can be useful in CLI applications or logging libraries.\n\nThe core of the package is the **Property** type. A property represents either\na color (foreground or background) or a text attribute (bold, underline, etc.).\nThe package also defines the **Style** type which is a collection of properties.\nStyles provide the ability to store a group of properties and reuse them when needed.\nBoth types come with the familiar [String](http://godoc.org/fmt#String),\n[Sprint](http://godoc.org/fmt#Sprint), [Sprintf](http://godoc.org/fmt#Sprintf)\nand [Sprintln](http://godoc.org/fmt#Sprintf) methods which are used the same as\nthe ones in the [fmt](http://godoc.org/fmt) package. Moreover, from a programming\nstandpoint, there is no difference between using a property and a style.\n\nFull documentation can be found at https://pkg.go.dev/github.com/adrg/splash.\n\n## Installation\n```\ngo get github.com/adrg/splash\n```\n## Usage\n\n#### Properties\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/adrg/splash\"\n)\n\nfunc main() {\n\treset := splash.Reset\n\n\t// Using text attributes\n\tfmt.Printf(\"%s%s%s \", splash.Bold, \"To boldly go\", reset)\n\tfmt.Printf(\"%s%s%s \", splash.Underline, \"where no man\", reset)\n\tfmt.Printf(\"%s%s%s\\n\", splash.Reverse, \"has gone before.\", reset)\n\n\t// Using foreground and background colors\n\tfmt.Printf(\"%s%s%s\\n\", splash.Red, \"Roses are red\", reset)\n\tfmt.Printf(\"%s%s%s\\n\", splash.BgGreen, \"Here's something new:\", reset)\n\tfmt.Printf(\"%s%s%s\\n\", splash.Magenta, \"Violets are violet\", reset)\n\tfmt.Printf(\"%s%s%s\\n\", splash.BgBlue, \"Not freaking blue!\", reset)\n\n\t// Combining colors with text attributes\n\tfmt.Printf(\"%s%s%s%s\\n\", splash.Bold, splash.Green, \"Hint: lamp\", reset)\n\tfmt.Printf(\"%s%s%s\\n\", splash.Red, splash.BgBlue, \"Hint: famous plumbler\")\n\n\tfmt.Println(reset)\n\n\t// Using property functions\n\tfmt.Println(splash.BgYellow.Sprint(\"Yellow there!\"))\n\tfmt.Print(splash.Green.Sprintln(\"The Wicked Witch of The West\"))\n\tfmt.Println(splash.Bold.Sprintf(\"%s%s\", splash.Blue, \"Don't feel blue!\"))\n}\n```\n\n\u003cimg alt=\"properties output\" src=\"https://raw.githubusercontent.com/adrg/adrg.github.io/master/assets/projects/splash/properties.png\" width=\"100%\" /\u003e\n\n#### Styles\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/adrg/splash\"\n)\n\nfunc main() {\n\t// Using styles\n\tinfo := splash.NewStyle(splash.Green, splash.Bold)\n\twarning := splash.NewStyle(splash.Yellow)\n\terr := splash.NewStyle(splash.Red, splash.Bold)\n\tcritical := splash.NewStyle(splash.Bold, splash.Yellow, splash.BgRed)\n\n\tfmt.Printf(\"%s%s%s\\n\", info, \"INFO: I'm so informative\", splash.Reset)\n\tfmt.Println(warning.Sprint(\"WARNING: You should not ignore me\"))\n\tfmt.Print(err.Sprintln(\"ERROR: You can't say I didn't warn you\"))\n\tfmt.Println(critical.Sprintf(\"%s %s\\n\", \"CRITICAL:\", \"This should be good\"))\n\n\t// Parsing styles\n\t// Format: foreground:background+attributes\n\tattr := splash.ParseStyle(\"+b\")\n\tfmt.Println(attr.Sprint(\"Bold\"))\n\n\tattrs := splash.ParseStyle(\"+bu\")\n\tfmt.Println(attrs.Sprint(\"Bold, underline\"))\n\n\tfg := splash.ParseStyle(\"yellow\")\n\tfmt.Println(fg.Sprint(\"Yellow foreground\"))\n\n\tbg := splash.ParseStyle(\":red\")\n\tfmt.Println(bg.Sprint(\"Red background\"))\n\n\tfgAttr := splash.ParseStyle(\"green+b\")\n\tfmt.Println(fgAttr.Sprint(\"Green foreground, bold\"))\n\n\tbgAttr := splash.ParseStyle(\":magenta+u\")\n\tfmt.Println(bgAttr.Sprint(\"Magenta background, underline\"))\n\n\tfgBg := splash.ParseStyle(\"cyan:red\")\n\tfmt.Println(fgBg.Sprint(\"Cyan foreground, red background\"))\n\n\tfgBgAttr := splash.ParseStyle(\"yellow:blue+b\")\n\tfmt.Println(fgBgAttr.Sprint(\"Yellow foreground, blue background, bold\"))\n\n\tfgBgAttrs := splash.ParseStyle(\"red:green+br\")\n\tfmt.Println(fgBgAttrs.Sprint(\"Red foreground, green background, bold, reverse\"))\n}\n```\n\n\u003cimg alt=\"styles output\" src=\"https://raw.githubusercontent.com/adrg/adrg.github.io/master/assets/projects/splash/styles.png\" width=\"100%\" /\u003e\n\n## Property reference\n\n\u003cimg alt=\"property reference\" src=\"https://raw.githubusercontent.com/adrg/adrg.github.io/master/assets/projects/splash/colors.png\" width=\"100%\" /\u003e\n\n**Foreground colors**\n```\nBlack Red Green Yellow Blue Magenta Cyan White\n```\n\n**Background colors**\n```\nBgBlack BgRed BgGreen BgYellow BgBlue BgMagenta BgCyan BgWhite\n```\n\n**Text attributes**\n```\nReset Bold Dim Italic Underline Blink FastBlink Reverse Hidden CrossedOut\n```\n\n * Note: unfortunately not all text attributes are supported in all terminals.\n\n## Style parsing reference\n\n**Format**\n```\nforeground:background+attributes\n```\n\n**Colors**\n```\nblack red green yellow blue magenta cyan white\n```\n\n**Text attributes**\n```\nb     - Bold\nd     - Dim\ni     - Italic\nu     - Underline\nB     - Blink\nf     - FastBlink\nr     - Reverse\nh     - Hidden\nc     - CrossedOut\nreset - Reset\n```\n\n## Contributing\n\nContributions in the form of pull requests, issues or just general feedback,\nare always welcome.  \nSee [CONTRIBUTING.MD](CONTRIBUTING.md).\n\n## References\n\nFor more information see the [ANSI escape sequences](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors)\nand [Terminal colors and formatting](http://misc.flogisoft.com/bash/tip_colors_and_formatting).\n\n## License\n\nCopyright (c) 2014 Adrian-George Bostan.\n\nThis project is licensed under the [MIT license](http://opensource.org/licenses/MIT).\nSee [LICENSE](LICENSE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrg%2Fsplash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrg%2Fsplash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrg%2Fsplash/lists"}