{"id":22267957,"url":"https://github.com/haideralipunjabi/cli-badges","last_synced_at":"2025-07-13T02:10:13.168Z","repository":{"id":62562589,"uuid":"289836506","full_name":"haideralipunjabi/cli-badges","owner":"haideralipunjabi","description":"Quirky little python package for generating badges for your cli apps.","archived":false,"fork":false,"pushed_at":"2020-12-21T14:26:24.000Z","size":90,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-17T01:50:39.122Z","etag":null,"topics":["badges","cli","cli-apps","cli-badges","generating-badges","hacktoberfest","italic","label","terminal","terminal-app"],"latest_commit_sha":null,"homepage":"","language":"Python","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/haideralipunjabi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/HAliPunjabi"]}},"created_at":"2020-08-24T05:29:54.000Z","updated_at":"2024-10-29T23:36:07.000Z","dependencies_parsed_at":"2022-11-03T15:30:53.754Z","dependency_job_id":null,"html_url":"https://github.com/haideralipunjabi/cli-badges","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/haideralipunjabi/cli-badges","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haideralipunjabi%2Fcli-badges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haideralipunjabi%2Fcli-badges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haideralipunjabi%2Fcli-badges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haideralipunjabi%2Fcli-badges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haideralipunjabi","download_url":"https://codeload.github.com/haideralipunjabi/cli-badges/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haideralipunjabi%2Fcli-badges/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080256,"owners_count":23708121,"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":["badges","cli","cli-apps","cli-badges","generating-badges","hacktoberfest","italic","label","terminal","terminal-app"],"created_at":"2024-12-03T11:09:47.602Z","updated_at":"2025-07-13T02:10:13.107Z","avatar_url":"https://github.com/haideralipunjabi.png","language":"Python","funding_links":["https://www.buymeacoffee.com/HAliPunjabi","https://ko-fi.com/logginjs');"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  ![](https://vectr.com/kerff/ddbmvyZmm.svg?width=600\u0026height=300\u0026select=aNbKxciPh)\n  \n  Quirky little python library for generating badges for your cli apps.\n  \n  ![GitHub file size in bytes](https://img.shields.io/github/size/haideralipunjabi/cli-badges/cli_badges/cli_badges.py?style=flat-square)\n  [![PyPI version](https://badge.fury.io/py/cli-badges.svg)](https://badge.fury.io/py/cli-badges)\n\u003c/div\u003e\n\n---\n\n**Inspired \u0026 Python Port of *[cli-badges - nombrekeff](https://github.com/nombrekeff/cli-badges)***\n\n## Getting Started\n\n### Installing\n\nAs usual, you need to install from PIP:\n\n```\n$ pip install cli-badges\n```\n\n### Usage\n\nThis is a simple example, using badges to display test results:\n\n```python\nfrom cli_badges import badge\n\nfailedBadge = badge(\"failed\",'2',messagebg='red')\nskippedBadge = badge('skipped', '1', messagebg='yellow',messagecolor='black')\nsuccessBadge = badge('success','8', messagebg='green',messagecolor='black')\n\n\nprint(failedBadge, successBadge, skippedBadge)\n```\n\nThe above would output something similar to the terminal:\n\n![output-example](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/basic-output-example.png)\n\nYou could also create a donate badge with a link ([if supported](#links)):\n\n```python\nfrom cli_badges import badge\n\ndonateBadge = badge('❤️ donate', 'ko-fi', messagelink='https://ko-fi.com/logginjs');\nprint(donateBadge)\n```\n\n![donate-output-example.png](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/donate-output-example.png)\n\nYou can also only show the label:\n\n```python\nfrom cli_badges import badge\n\nonlyLabel = badge('❤️ donate', '')\nprint(onlyLabel)\n```\n![onlylabel-output-example](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/onlylabel-output-example.png)\n\n\u003e Example output is a mock, console output will vary slightly from terminal to terminal.\n\n## Badge Structure\n\nA badge is conformed of a label and a message `\u003clabel\u003e:\u003cmessage\u003e`. Each segment can be customized, by changing bg color, text color and style.\n\n## Available Options\n\n| Option | Value | Default |\n|   ---  |  ---  |   ---   |\n| label  | String | `''`     |\n| message| String | `''`     |\n| messagebg | Color | blue |\n| labelbg | Color | dark_gray |\n| messagecolor | Color | white |\n| labelcolor | Color | white |\n| labelwidth | Integer | label length + 2|\n| messagewidth | Integer | label length + 2|\n| labelstyles | Array of Styles | `[]` |\n| messagestyles | Array of Styles | `[]`|\n| labellink | URL | `''` |\n| messagelink | URL | `''`|\n| swap | boolean | False |\n| theme | Theme | None |\n\n### Colors\n\n`cli-badges` uses [`colored`](https://pypi.org/project/colored/) internally for managing colors, you can check the list of available colors there.\n\n### Styles\n`cli-badges` uses [`colored`](https://pypi.org/project/colored/) internally for managing styles, you can check the list of available styles there.\n\n#### Available Styles\n\n* bold\n* dim\n* underlined\n* reverse\n* hidden\n\n### Links\n\nYou can output badges with a link attached to it, that can be clicked in some terminals. `labellink` option will add the link to the label, while `messagelink` option will add the link to the message.\n\n\u003e #### ⚠︎ cli-badges will only output link if its supported by your terminal.\n\n\u003e See [this](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) for information on supported terminals\n\n```python\nbadge('with', 'link',  labellink='https://link.com', messagelink='https://link2.com');\n```\n![withlink-output-example](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/withlink-output-example.png)\n\n\n### Themes\n\n![theme-image](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/themes.png)\n\nThemes are a way to store badge configuration for repeated use. All the options (except for the theme option, obviously) that are needed by the badge can be stored by making a theme.  \nThe library comes with a set of inbuilt themes, but you can also define your own\n\n#### Inbuilt Themes\n\n* **red** : Red Message Background\n* **green** : Green Message Background\n* **yellow** : Black Colored Message on Yellow Background\n* **cyan** : Black Colored Message on Cyan Background\n* **magenta** : Black Colored Message on Magenta Background\n* **success** : 'Success' Message on Green Background\n* **failed** : 'Failed' Message on Red Background\n\n#### Using Themes\n\n`THEME` stores all the available themes, and has to be passed to the `badge()` functions `theme` argument. Arguments present in the theme will override the passed arguments. Missing arguments will have default values\n\n```python\nfrom cli_badges import badge,THEME\nred_badge = badge('Red','Badge',theme=THEME.red)\nprint(red_badge)\n```\n\n#### Adding New Themes\n\n1. Directly in Code  \nTo add a Theme directly, `add_theme(name,config)` function is used. `name` is the name of the theme, `config` is a `dict` containing the required options\n\n    ```python\n    from cli_badges import badge,add_theme, THEME\n    add_theme('donate',{\n        'label': '❤️ donate'\n    })\n    donate_badge = badge(message='kofi',theme=THEME.donate)\n    print(donate_badge)\n    ```\n  \n2. From a JSON File  \nYou can store the Theme configurations in a `json` file and load them using `load_themes(file)` function where `file` is the Theme `json` file\n\n    ```json\n    # themes.json\n    {\n        \"redblue\": {\n            \"messagebg\": \"blue\",\n            \"labelbg\":\"red\",\n            \"messagestyles\": [\"bold\"]\n        }\n    }\n    ```\n\n    ```python\n    from cli_badges import badge, load_themes, THEME\n    load_themes(open(\"themes.json\",\"r\"))\n    redblue_badge = badge('RED','BLUE',theme=THEME.redblue)\n    print(redblue_badge)\n    ```\n\n### Swapping Styles\n\nThe `swap` option is used to apply the message styles to the label and vice-versa\n\n```python\nfrom cli_badges import badge\nnormal_badge = badge('RED','BLUE',labelbg='red', messagebg='blue')\nswapped_badge = badge('RED','BLUE',labelbg='red', messagebg='blue',swap=True)\nprint(normal_badge,swapped_badge)\n```\n![swap-example](https://raw.githubusercontent.com/haideralipunjabi/cli-badges/master/invert-example.png)\n\n### Other Libraries?\n\ncli-badges is also available in other languages:\n\n- `Node` [@nombrekeff/cli-badges](https://github.com/nombrekeff/cli-badges)\n- `Deno` [@Delta456/cli_badges](https://github.com/Delta456/cli_badges)\n---\n\nContributions are very welcomed 🥰","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaideralipunjabi%2Fcli-badges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaideralipunjabi%2Fcli-badges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaideralipunjabi%2Fcli-badges/lists"}