Skip to content
the tiny command-line interface library with lots of style~ http://gemcutter.org/gems/mutter
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.document
.gitignore
LICENSE
README.md
Rakefile
VERSION
mutter.gemspec

README.md

mutter

$ my words come out, 
    in color and
        style

mutter takes the concepts of separation of style & content to the command-line!

synopsis

require 'mutter'

mut = Mutter.new                # creates a new 'Mutterer', who talks in command-line language
mut.say "hello _world_"         # underlines 'world'
mut.say "hello world",   :bold  # bolds the whole string
mut.say "hello [world]", :cyan  # inverts 'world', and colors the string cyan
mut.print "bonjour!"            # alias of `say`
mut["_hola_"]                   # return the stylized string without printing

styles

mutter supports these styles:

:bold, :underline, :inverse, :blink

and these colors:

:red, :green, :blue, :yellow, :cyan, :purple, :white, :black

customization

styles = {
  :warning => {                     # an alias you can use anywhere in mutter
    :match => ['*!', '!*'],         # will match *!mutter!*
    :style => ['yellow', 'bold']    # these styles will be applied to the match
  },
  :error => {
    :match => '!!',                 # will match !!mutter!!
    :style => ['red', 'underline']
  }
}

mut = Mutter.new(styles)
mut.say     "warning, the dogs have escaped!", :warning  # These two are
mut.warning "warning, the dogs have escaped!"            # equivalent
mut.say     "gosh, we have an !!error!!"

YAML

The previous example could have (and should really have) been written in a separate .yml file, like so:

warning:
  match: 
    - '*!'
    - '!*
  style:
    - yellow
    - bold

error:
  match: '!!'
  style:
    - red
    - underline

and then loaded like this:

Mutter.new("styles.yml")

quick styles

mut = Mutter.new :yellow => '~'
mut.say "~[black on yellow!]~"

add/remove styles from an instance

mut = Mutter.new(:blink)
mut >> :blink               # remove :blink
mut << :bold << :underline  # add :bold and :underline
mut.say "hello mutter."     # bold and underlined

installation

$ sudo gem install cloudhead-mutter

That's it!

have fun

Footnote

This code is highly experimental, don't try this at home!

Something went wrong with that request. Please try again.