https://github.com/voxel51/badger
Python CLI for creating, saving, and managing custom badges
https://github.com/voxel51/badger
Last synced: 4 days ago
JSON representation
Python CLI for creating, saving, and managing custom badges
- Host: GitHub
- URL: https://github.com/voxel51/badger
- Owner: voxel51
- License: apache-2.0
- Created: 2023-08-26T00:49:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-12T00:33:23.000Z (over 1 year ago)
- Last Synced: 2024-12-04T04:33:17.336Z (4 months ago)
- Language: Python
- Size: 129 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - voxel51/badger - Python CLI for creating, saving, and managing custom badges (Python)
README
# ðĶĄ Badger - Custom Badges Made Easy ð
[](https://github.com/voxel51/badger)
[](https://github.com/voxel51/badger/blob/main/LICENSE)---
## ð Introduction
Ever felt the need to spice up your GitHub README with cool badges, but found it too tedious? Want to personalize your badges to showcase your style? **Badger** is here to the rescue! ð
**Badger** is a Python CLI tool that allows you to generate custom badges for your GitHub README or any other markdown files. With a simple command, you can create, manage, and insert badges like a pro. ð
## ð Features
- Create badges with custom text, colors, and logos ðĻ
- Save badge configurations for future use ð
- Generate badges on-the-fly and copy them to clipboard ð
- List, delete, and manage your badges effortlessly ð## ðĶ Installation
Installing **Badger** is as simple as pie:
```bash
git clone https://github.com/voxel51/badger.git
cd badger
pip install -e .
```If you want to use Badger with SVGs hosted on the web, you will need to install `requests`. Change the last line to:
```bash
pip install -e ".[web]"
```If you want to use the `badger go-wild` command, you will need to install `openai`. Change the last line to:
```bash
pip install -e ".[wild]"
```And make sure to set your OpenAI API key as an environment variable:
```bash
export OPENAI_API_KEY=
```To install both, change the last line to:
```bash
pip install -e ".[web,wild]"
```## ð Usage
Here's how you can use Badger:
### ðïļ Create a New Badge
```bash
badger create badge_name
```This will walk you through a series of prompts to customize your badge.
```bash
badger create voxel51_ada
```Begins the process of creating an ADA compliant badge for Voxel51 named `voxel51_ada`:
```plaintext
> [REQUIRED] Enter a name for this badge: voxel51_ada
> [OPTIONAL] Enter the badge text: voxel51
Commonly used colors:
1. brightgreen
2. green
3. yellowgreen
4. yellow
5. orange
6. red
7. blue
8. lightgrey
9. success
10. important
11. critical
12. informational
13. inactive> [OPTIONAL] Enter the color of the badge (or choose a number from the list above): blue
> [REQUIRED] Enter the badge logo: https://gist.githubusercontent.com/jacobmarks/eb18cc90596f7310e4dad1be2526c070/raw/e05e51be697a9501f64fe8d1b7008fc5ebe56369/fiftyone_icon.svg
> [REQUIRED] Enter the badge URL: https://github.com/voxel51/fiftyone
> [OPTIONAL] Enter the badge style: flat
> [OPTIONAL] Enter the badge logoColor: white
> [OPTIONAL] Enter the badge label:
> [OPTIONAL] Enter the badge labelColor:
> [OPTIONAL] Enter the badge logoWidth:
> Successfully added badge 'voxel51_ada'.
```ðĄ As show in this example, you can create a badge from an SVG at a URL! If you do so, the content of the SVG will be retrieved at badge generation time using `requests`. You can also use local SVGs by specifying the relative or absolute path to the SVG file.
#### ðĄ Simple Mode
You can also create a badge in simple mode by passing the `--simple` flag:
```bash
badger create --simple --badge_name simple_badge --logo assets/fiftyone.svg --url https://github.com/voxel51/fiftyone --text FiftyOne
```This will bypass the optional prompts and create a badge with the specified parameters. The `--simple` flag can be used anywhere in the command, before or after the `create` command.
If you find yourself wanting to use this mode often, you can create an alias for it:
```bash
alias badgers="badger create --simple"
```### ð Copy a Badge to Clipboard
```bash
badger copy badge_name
```This copies the badge markdown to your clipboard. Paste it wherever you like!
For instance, we can copy the badge we just created:
```bash
badger copy voxel51_ada
```[](https://github.com/voxel51/fiftyone)
### ðĻïļ Print a Badge Markdown
```bash
badger print badge_name
```Prints the badge markdown to the terminal.
### ð List All Badges
```bash
badger list
```Lists all the badges you have created.
```plaintext
Available badges:
Badge Name URL Color Text
--------------------------------------------------------------------------------------------------------------
badger https://github.com/voxel51/badger blue Badger
voxel51 https://github.com/voxel51/fiftyone blue voxel51
voxel51_ada https://github.com/voxel51/fiftyone blue voxel51
svg-repo-atom https://www.svgrepo.com/svg/530661/genetic-data grey Atom
```### ðïļ Delete a Badge
```bash
badger delete badge_name
```Deletes the badge from your config file.
### ðŠ Clone a Badge
```bash
badger clone badge_name new_badge_name
```Clones the badge with the name `badge_name` and saves it with the name `new_badge_name`.
### ðïļ Edit a Badge
```bash
badger edit badge_name --color success
```Edits the badge with the name `badge_name` and sets the color to `success`.
### âđïļ Get Info About a Badge
```bash
badger info badge_name
```Prints information about the badge with the name `badge_name`.
```plaintext
Badge: badger
--------------------------------------------------------------------------------------------------------------
URL: https://github.com/voxel51/badger
Color: blue
Text: Badger
Logo: /Users/jacobmarks/Desktop/work/badger/assets/badger.svg
Style: flat
Label: N/A
Label Color: grey
Logo Width: N/A
Logo Color: white
```### âĻ Go Wild!
```bash
badger go-wild
```Generates a random badge using AI and copies it to your clipboard. ðĪŠ This takes a `--prompt` argument that allows you to specify the prompt to use for generating the badge.
For example:
```bash
badger go-wild --prompt turtle
```Creates a trial badge for the turtle prompt.
[](https://github.com/voxel51/badger)
You can then save the badge to your config file by entering `y` when prompted and follow the instructions to save the badge.
And:
```bash
badger go-wild --prompt flamingo
```[](https://github.com/voxel51/badger)
> ðĄ This uses your OpenAI API Key to call GPT 4
### â Get Help
```bash
badger help
```Prints the help message.
### ðĻ Customization
- Custom Colors
- Custom Logos
- Custom Text
- Custom Styles
- ... and much more! ðOnce you have created a badge (added it to your config), you can work with modified versions of that badge incredibly easily using the following command line arguments, which can be passed along with the `copy` and `print` commands:
- `--logo`: The logo color of the badge
- `--url`: The URL the badge points to
- `--style`: The style of the badge
- `--color`: The color of the badge
- `--text`: The text of the badge
- `--label`: The label of the badge
- `--labelColor`: The label color of the badge
- `--logoColor`: The logo color of the badge
- `--logoWidth`: The logo width of the badge### Editing the Config File
You can also edit the config file directly to customize your badges. The config file is located at `~/.badger/config.yaml` and has the following format:
```yml
badges:
badger:
color: blue
labelColor: grey
logo: /Users/jacobmarks/Desktop/work/badger/assets/badger.svg
logoColor: white
style: flat
text: Badger
url: https://github.com/voxel51/badger
voxel51:
color: blue
logo: https://gist.githubusercontent.com/jacobmarks/eb18cc90596f7310e4dad1be2526c070/raw/e05e51be697a9501f64fe8d1b7008fc5ebe56369/fiftyone_icon.svg
text: voxel51
url: https://github.com/voxel51/fiftyone
voxel51_ada:
color: blue
logo: /Users/jacobmarks/Desktop/work/badger/assets/fiftyone.svg
logoColor: white
text: voxel51
url: https://github.com/voxel51/fiftyone
svg-repo-atom:
color: grey
labelColor: blue
logo: https://www.svgrepo.com/download/530661/genetic-data.svg
logoColor: white
text: Atom
url: https://www.svgrepo.com/svg/530661/genetic-data
style: plastic
```You can add, remove, and edit badges as you see fit. Badger will automatically detect changes to the config file and update your badges accordingly.
ðĄ You can also set the location of the config file in your environment variables using the `BADGER_CONFIG_DIR` variable.
## Where to Get Badges
If you're looking for some cool badges to use, check out these resources:
### Free-to-Use SVGs
- [Simple Icons](https://simpleicons.org/)
- [SVG Repo](https://www.svgrepo.com/)
- [Icon Monstr](https://iconmonstr.com/)
- [Font Awesome](https://fontawesome.com/)Because `Badger` supports copying and printing badges with SVGs at URLs, you can use any of the above resources to generate badges on-the-fly! ð
Just click into the SVG you want to use, copy the URL, and use it as the `logo` argument when creating a badge.
Here's an example from SVG Repo with [this](https://www.svgrepo.com/svg/530661/genetic-data) SVG:
```yaml
badges:
...
svg-repo-atom:
color: grey
logo: https://www.svgrepo.com/download/530661/genetic-data.svg
logoColor: white
text: Atom
url: https://www.svgrepo.com/svg/530661/genetic-data
style: for-the-badge
...
```With this in your Badger config file, running `badger copy svg-repo-atom` will copy the following badge to your clipboard: [](https://www.svgrepo.com/svg/530661/genetic-data)
### Simplifying SVGs
Occassionally, you may find that the SVG you want to use is too complex for shields.io or Github's rendering handle. In this case, you can simplify the SVG using the SVG optimizer [SVGO](https://github.com/svg/svgo).
You can install SVGO using:
```bash
npm install -g svgo
```And then simplify your SVG using:
```bash
svgo -i input.svg -o output.svg
```## ðĄ Why You Absolutely Need This
- Saves Time: No need to manually write markdown or HTML for badges. ð
- Be Unique: Stand out from the crowd with personalized badges. ðĶ
- Stay Organized: Keep all your badges in one place, ready to be used anytime. ð
- It's Cool: Because let's face it, who doesn't like badges? ð## Acknowledgements
Huge shout out to [Rustem Galiullin](https://github.com/Rusteam) and [Kishan Savant](https://github.com/NeoKish) for beta-testing the tool and providing valuable feedback!
- [Shields.io](https://shields.io/) for the awesome badges