Sha256: 39ae4798ce0e0c4d39fd493a1b567569799555de138d3b41e0e91efdf2966ead

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby

Signal.trap("INT") { exit 1 }

require 'pastel'

help = <<-EOS
PASTEL(1)

NAME
    patel -- color string and print

SYNOPSIS
    pastel [--enabled] style [style ...] TEXT

DESCRIPTION
    Use this command line tool to apply colors and style to terminal output.

    All the extra parameters can be applied individually or mixed to create
    desired effect.

    The options:
    --enabled   This option causes pastel to enforce string coloring
                regardless whether terminal supports ANSI escape color
                sequences or not.

EXAMPLES
    The command:

        pastel green foo

    will print the 'foo' string to the standard output in green color.

    The command:

        pastel green on_red foo

    will print the 'foo' string to the standard output in green color and
    on the red background.

    The command:

        echo foo | pastel green

    will read the content 'foo' and pipe it to pastel to print to standard
    output.

SEE ALSO
    https://github.com/peter-murach/pastel
EOS
opts = {}

if ARGV.empty? || ARGV.any? { |a| %w(--help -h).include?(a) }
  puts help
  exit
elsif !(index = ARGV.index('--enabled')).nil?
  ARGV.delete_at(index)
  opts = {enabled: true}
end

text = STDIN.tty? ? ARGV.pop : $stdin.read.chomp

pastel = Pastel.new(opts)

print pastel.decorate(text, *ARGV.map(&:to_sym))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pastel-cli-0.3.0 bin/pastel
pastel-cli-0.2.0 bin/pastel