mirror of
https://github.com/GeopJr/BLAHAJ.git
synced 2025-03-26 07:04:41 +01:00
feat: load custom colors yaml at runtime (#15)
* feat: load custom colors yaml at runtime * feat: handle parsing errors and update README, ci
This commit is contained in:
parent
b36599b924
commit
a1fcded3c1
3 changed files with 35 additions and 38 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
echo "VERSION=$(shards version)" >> "$GITHUB_OUTPUT"
|
||||
id: version
|
||||
- name: Build
|
||||
run: make static_mt
|
||||
run: make static
|
||||
- name: Make binary executable
|
||||
run: chmod +x bin/blahaj
|
||||
- name: Upload artifact
|
||||
|
|
63
README.md
63
README.md
|
@ -10,65 +10,52 @@
|
|||
<a href="https://github.com/GeopJr/BLAHAJ/actions"><img src="https://img.shields.io/github/actions/workflow/status/GeopJr/BLAHAJ/ci.yml?branch=main&labelColor=5992a4&style=for-the-badge" alt="ci action status" /></a>
|
||||
</p>
|
||||
|
||||
#
|
||||
|
||||
## What is BLÅHAJ?
|
||||
# What is BLÅHAJ?
|
||||
|
||||
Apart from [a cute cuddly shark plushie from IKEA](https://www.ikea.com/us/en/p/blahaj-soft-toy-shark-90373590/), BLÅHAJ is a lolcat-like CLI tool that colorizes your input, shows flags and prints colorful sharks!
|
||||
|
||||
It has a wide variety of flags/colors to choose from and many options from flag size to whether to colorize by line, word or character.
|
||||
|
||||
#
|
||||
# Installation
|
||||
|
||||
## Installation
|
||||
|
||||
### Pre-built
|
||||
## Pre-built
|
||||
|
||||
You can download one of the statically-linked pre-built binaries from the [releases page](https://github.com/GeopJr/BLAHAJ/releases/latest).
|
||||
|
||||
They are built & published by our lovely [actions](https://github.com/GeopJr/BLAHAJ/actions/workflows/release.yml).
|
||||
|
||||
### AUR
|
||||
## AUR
|
||||
|
||||
Arch Linux users can install the [blahaj](https://aur.archlinux.org/packages/blahaj) (or the [blahaj-git](https://aur.archlinux.org/packages/blahaj-git)) AUR package.
|
||||
|
||||
### Docker
|
||||
## Docker
|
||||
|
||||
```
|
||||
docker run --rm -it --name blahaj ghcr.io/geopjr/blahaj -h
|
||||
```
|
||||
|
||||
### Building
|
||||
## Building
|
||||
|
||||
#### Dependencies
|
||||
### Dependencies
|
||||
|
||||
- `crystal` - `1.8.0`
|
||||
|
||||
#### Makefile
|
||||
### Makefile
|
||||
|
||||
- `$ make` (or `$ make static` on Alpine Linux for a static build)
|
||||
- `# make install`
|
||||
|
||||
##### Multithreading
|
||||
# FAQ
|
||||
|
||||
Releases are already in mt mode. It makes BLÅHAJ a *lot* faster:
|
||||
|
||||
- `$ make build_mt` (or `$ make static_mt` on Alpine Linux for a static build)
|
||||
- `# make install`
|
||||
|
||||
#
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why are only striped flags allowed?
|
||||
## Why are only striped flags allowed?
|
||||
|
||||
Flags with eg. triangles, circles or symbols, need enough horizontal space to determine where and how to display them. BLÅHAJ can't know in advance how long the input is going to be.
|
||||
|
||||
### Why are the stripes repeating instead of showing the flag in full?
|
||||
## Why are the stripes repeating instead of showing the flag in full?
|
||||
|
||||
Just like the previous question, BLÅHAJ can't know how long the text is going to be (vertically) since it colorizes the input as it comes in.
|
||||
|
||||
### I would like to add a color scheme or flag
|
||||
## I would like to add a color scheme or flag
|
||||
|
||||
Great! Follow the [Contributing section](#contributing) and modify [data/colors.yaml](./data/colors.yaml).
|
||||
|
||||
|
@ -83,9 +70,7 @@ flag name:
|
|||
- if any
|
||||
```
|
||||
|
||||
#
|
||||
|
||||
## Examples
|
||||
# Examples
|
||||
|
||||
```
|
||||
$ blahaj -h
|
||||
|
@ -118,29 +103,35 @@ Arguments:
|
|||
-h, --help Show this help
|
||||
```
|
||||
|
||||
### Shark (`-s`), flag (`-f`), flag with 2x multiplier (`-f -m 2`)
|
||||
## Shark (`-s`), flag (`-f`), flag with 2x multiplier (`-f -m 2`)
|
||||
|
||||

|
||||
|
||||
### Pipe, individual characters instead of rows (`-i`)
|
||||
## Pipe, individual characters instead of rows (`-i`)
|
||||
|
||||

|
||||
|
||||
### Read from file, background instead of foreground (`-b`), individual words instead of rows (`-w`)
|
||||
## Read from file, background instead of foreground (`-b`), individual words instead of rows (`-w`)
|
||||
|
||||
> Notice how the foreground color changes based on the background color.
|
||||
|
||||

|
||||
|
||||
### Pipe, default color scheme
|
||||
## Pipe, default color scheme
|
||||
|
||||

|
||||
|
||||
> All images above include ALT text and you are encouraged to read it, if you find parts of them confusing, by using screen readers, hovering over them with your cursor or looking at the source.
|
||||
|
||||
#
|
||||
# Custom flags at runtime
|
||||
|
||||
## Contributing
|
||||
You can pass a local [`./data/colors.yaml`](./data/colors.yaml) file at runtime to the `BLAHAJ_COLORS_YAML` env var and BLÅHAJ will parse it. This can also be used to override the already defined flags.
|
||||
|
||||

|
||||
|
||||
(The custom file needs to follow the [`./data/colors.yaml`](./data/colors.yaml) format)
|
||||
|
||||
# Contributing
|
||||
|
||||
1. Read the [Code of Conduct](https://github.com/GeopJr/BLAHAJ/blob/main/CODE_OF_CONDUCT.md)
|
||||
2. Fork it ( https://github.com/GeopJr/BLAHAJ/fork )
|
||||
|
@ -149,9 +140,7 @@ Arguments:
|
|||
5. Push to the branch (git push origin my-new-feature)
|
||||
6. Create a new Pull Request
|
||||
|
||||
#
|
||||
|
||||
## Sponsors
|
||||
# Sponsors
|
||||
|
||||
<p align="center">
|
||||
|
||||
|
|
|
@ -19,6 +19,14 @@ require "./blahaj/*"
|
|||
{% skip_file if @top_level.has_constant? "Spec" %}
|
||||
|
||||
module Blahaj
|
||||
if !(custom_colors = ENV["BLAHAJ_COLORS_YAML"]?).nil? && File.exists?(custom_colors)
|
||||
begin
|
||||
COLORS.merge!(Flags.new(File.read(custom_colors)).flags)
|
||||
rescue
|
||||
puts "\"#{custom_colors}\" does not follow the colors.yaml spec.".colorize(:red)
|
||||
end
|
||||
end
|
||||
|
||||
Blahaj::CLI.new(ARGV)
|
||||
Blahaj::Colorizer.new
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue