{"id":15406898,"url":"https://github.com/dannyben/colsole","last_synced_at":"2025-04-18T03:15:30.650Z","repository":{"id":32023717,"uuid":"35594956","full_name":"DannyBen/colsole","owner":"DannyBen","description":"Utility functions for colorful console applications with Ruby","archived":false,"fork":false,"pushed_at":"2024-02-26T08:37:40.000Z","size":459,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T14:12:04.921Z","etag":null,"topics":["cli-utilities","gem","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/DannyBen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2015-05-14T06:28:46.000Z","updated_at":"2024-01-12T18:05:11.000Z","dependencies_parsed_at":"2024-02-26T09:43:20.811Z","dependency_job_id":null,"html_url":"https://github.com/DannyBen/colsole","commit_stats":{"total_commits":136,"total_committers":2,"mean_commits":68.0,"dds":0.4558823529411765,"last_synced_commit":"4549cbb3b851db0224d117860b0918392cd85f84"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fcolsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fcolsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fcolsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fcolsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/colsole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":220053640,"owners_count":16588698,"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":["cli-utilities","gem","ruby"],"created_at":"2024-10-01T16:26:06.620Z","updated_at":"2024-10-17T12:23:11.641Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Colsole\n\n[![Gem Version](https://badge.fury.io/rb/colsole.svg)](https://badge.fury.io/rb/colsole)\n[![Build Status](https://github.com/DannyBen/colsole/workflows/Test/badge.svg)](https://github.com/DannyBen/colsole/actions?query=workflow%3ATest)\n[![Maintainability](https://api.codeclimate.com/v1/badges/0556015f7cd2080531a1/maintainability)](https://codeclimate.com/github/DannyBen/colsole/maintainability)\n\n---\n\nUtility functions for colorful console applications.\n\n\u003e **Upgrade Note**\n\u003e \n\u003e - Version 1.0.x is not compatible with older versions\n\u003e - Version 0.8.x is compatible with both the old syntax and new syntax\n\u003e \n\u003e See [Upgrading](#upgrading) below.\n\n## Install\n\nAdd to your Gemfile:\n\n```\n$ gem 'colsole', '\u003e= 0.8.1', '\u003c 2.0'\n```\n\n## Usage\n\n```ruby\nrequire 'colsole'\ninclude Colsole\nsay 'b`Blue` Man Group'\n```\n\nAll the methods described below can also be called directly on the `Colsole` module. This is useful when you want to use it at the top level of your project, without namespace contamination:\n\n```ruby\nrequire 'colsole'\nColsole.say 'b`Blue` Man Group'\n```\n\n## Examples\n\nSee the [Examples file](https://github.com/DannyBen/colsole/blob/master/example.rb).\n\n## Primary Functions\n\n### `say \"anything\"`\n\nAn alternative to puts with line wrapping, colors and more.\n\n```ruby\nsay \"Hello\"\n```\n\nLeave a trailing space to keep the cursor at the same line\n\n```ruby\nsay \"appears in \"\nsay \"one line\"\n```\n\nEmbed [color markers](#colors) in the string:\n\n```ruby\nsay \"This is r`red`, and this gu`entire phrase is green underlined`\"\n```\n\nProvide the `replace: true` option after a space terminated \"said\" string to\nrewrite the line:\n\n```ruby\n# space terminated string to say it without a newline\nsay \"downloading data... \"\n# long process here...\nsay \"download complete.\", replace: true\n```\n\n### `word_wrap \"   string\" [, length]`\n\nWrap long lines while keeping words intact, and keeping indentation based on the\nleading spaces in your string:\n\n```ruby\nsay word_wrap(\"    one two three four five\", 15)\n\n# output:\n#    one two\n#    three four\n#    five\n```\n\nIf `length` is not provided, `word_wrap` will attempt to determine it\nautomatically based on the width of the terminal.\n\n### `say! \"anything to stderr\"`\n\nUse say! to output to stderr with color markers:\n\n```ruby\n# red inverted ERROR\nsay! \"ri` ERROR ` This just did not work\"\n```\n\n## Utility / Support Functions\n\n### `colorize \"string\"`\n\nParses and returns a color-flagged string.\n\n### `terminal?`\n\nReturns true if we are running in an interactive terminal\n\n### `command_exist? \"some_executable\"`\n\nChecks if the provided string is a command in the path.\n\n### `terminal_size [fallback_cols, fallback_rows]`\n\nReturns an array `[width, height]` of the terminal, or the supplied \nfallback if it is unable to detect.\n\n### `terminal_width` / `terminal_height`\n\nReturns only the terminal width or height. This is a shortcut to \n`terminal_size[0]` / terminal_size[1].\n\n## Colors\n\nStrings that are surrounded by backticks, and preceded by a color code and\noptional styling markers will be converted to the respective ANSI color.\n\n```ruby\nsay \"this is b`blue` and ru`this is red underlined`\"\n```\n\nThe one letter color code is required, followed by up to 3 style code.\n\n| Color Code | Color    |\n| ---------- | -------- |\n| `n`        | no color |\n| `k`        | black    |\n| `r`        | red      |\n| `g`        | green    |\n| `y`        | yellow   |\n| `b`        | blue     |\n| `m`        | magenta  |\n| `c`        | cyan     |\n| `w`        | white    |\n\n| Style Code | Style      |\n| ---------- | ---------- |\n| `b`        | bold       |\n| `u`        | underlined |\n| `i`        | inverted   |\n| `z`        | terminate  |\n\n## Upgrading\n\nVersion 0.8.x changes several things, including the syntax of the color\nmarkers. For easy transition, it is compatible with older versions.\n\nFollow these steps to upgrade:\n\n```ruby\n# =\u003e Require a more flexible version\n# change this\ngem 'colsole'\n# to this\ngem 'colsole', '\u003e= 0.8.1', '\u003c 2.0'\n\n# =\u003e Remove 'say_status'\n# It will no longer be supported in 1.0.0\nsay_status \"text\"\n\n# =\u003e Replace 'resay'\n# 'resay' is replaced with 'say replace: true'\n# change this\nresay \"text\"\n# to this\nsay \"text\", replace: true\n\n# =\u003e Change color markers syntax\n# replace this\nsay \"the !txtblu!blue\"\n# with this\nsay \"the b`blue`\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fcolsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fcolsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fcolsole/lists"}