Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Sija/climate.cr
Tiny tool to make your CLI output ๐ coloured
https://github.com/Sija/climate.cr
cli crystal
Last synced: 3 months ago
JSON representation
Tiny tool to make your CLI output ๐ coloured
- Host: GitHub
- URL: https://github.com/Sija/climate.cr
- Owner: Sija
- License: mit
- Created: 2020-05-21T23:05:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-12T15:42:49.000Z (about 1 year ago)
- Last Synced: 2024-06-21T18:09:57.083Z (5 months ago)
- Topics: cli, crystal
- Language: Crystal
- Homepage:
- Size: 19.5 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - climate - Tiny tool to make your CLI output ๐ coloured (CLI Utils)
README
# climate.cr [![CI](https://github.com/Sija/climate.cr/actions/workflows/ci.yml/badge.svg)](https://github.com/Sija/climate.cr/actions/workflows/ci.yml) [![Releases](https://img.shields.io/github/release/Sija/climate.cr.svg)](https://github.com/Sija/climate.cr/releases) [![License](https://img.shields.io/github/license/Sija/climate.cr.svg)](https://github.com/Sija/climate.cr/blob/master/LICENSE)
Small helper utility to make your CLI program output ๐ coloured by means
of configurable markup styles. Think of it as your CLI-mate :)## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
climate:
github: Sija/climate.cr
```2. Run `shards install`
## Usage
```crystal
require "climate"message = "Usage: {#{PROGRAM_NAME}} [optional-arg]"
# you can call `Climate.parse` method directly
puts Climate.parse(message)# or use a `String#climatize` extension
puts message.climatize
```### Defaults
Default styles are:
- `<>` colored in _green_ (keeping delimiters)
- `[]` colored in _yellow_ (keeping delimiters)
- `{}` colored in _blue_ (hiding delimiters)
- `!ยก` colored in _red_ (hiding delimiters)### Configuration
You can change the global settings with a `#configure` block:
```crystal
Climate.configure do |settings|
# use defaults
settings.use_defaults!# and/or configure your own styles
settings.styles << Climate::Style.new(
delimiters: {'?', 'ยฟ'},
keep_delimiters: false,
colors: {
fore: :magenta,
back: :default,
},
decoration: :bold
)
end
```For the `colors` and `decoration` reference values see
documentation for the [`Colorize`](https://crystal-lang.org/api/Colorize.html)
module (which `Climate` uses under the hood).## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Sijawusz Pur Rahnama](https://github.com/Sija) - creator and maintainer