Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tiny tool to make your CLI output 🌈 coloured

License

Notifications You must be signed in to change notification settings

Sija/climate.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

climate.cr CI Releases 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:

    dependencies:
      climate:
        github: Sija/climate.cr
  2. Run shards install

Usage

require "climate"

message = "Usage: {#{PROGRAM_NAME}} <required-arg> [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:

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 module (which Climate uses under the hood).

Contributing

  1. Fork it (https://github.com/Sija/climate.cr/fork)
  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

About

Tiny tool to make your CLI output 🌈 coloured

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •