README.md in everyday-cli-utils-1.1.0 vs README.md in everyday-cli-utils-1.2.0

- old
+ new

@@ -4,12 +4,14 @@ [![Build Status](https://travis-ci.org/henderea/everyday-cli-utils.png?branch=master)](https://travis-ci.org/henderea/everyday-cli-utils) [![Dependency Status](https://gemnasium.com/henderea/everyday-cli-utils.png)](https://gemnasium.com/henderea/everyday-cli-utils) [![Code Climate](https://codeclimate.com/github/henderea/everyday-cli-utils.png)](https://codeclimate.com/github/henderea/everyday-cli-utils) [![Coverage Status](https://coveralls.io/repos/henderea/everyday-cli-utils/badge.png?branch=master)](https://coveralls.io/r/henderea/everyday-cli-utils?branch=master) -A few CLI and general utilities. Includes a numbered-menu select loop utility, a ANSI formatting escape code handler, a text-based histogram maker, k-means and n-means (k-means with minimum optimal k) calculators, various collection utility methods, a Curses wrapper with up/down scrolling and more handled easily, and a utility for using OptionParser with less code. +A few CLI and general utilities. Includes a numbered-menu select loop utility, a ANSI formatting escape code handler, a text-based histogram maker, k-means and n-means (k-means with minimum optimal k) calculators, various collection utility methods, and a utility for using OptionParser with less code. +Note: The curses utility has been moved to the `everyday-curses` gem + ## Issue Tracking Please use <https://everydayprogramminggenius.atlassian.net/browse/ECU> for issue tracking. ## Installation @@ -153,14 +155,42 @@ Much shorter, right? There is also a static version of the method in `EverydayCliUtils::Format` that takes the string as a parameter, for those of you that use the "safe" version. +Here's the two-letter color keys: + +```ruby +{ + 'bk' => :black, + 'rd' => :red, + 'gr' => :green, + 'yw' => :yellow, + 'bl' => :blue, + 'pu' => :purple, + 'cy' => :cyan, + 'wh' => :white, + 'no' => :none +} +``` + As of version 0.5.0, there is now a `String#mycenter` method that takes a length and an optional character (defaults to `' '`) and centers the string using that character and length. This is designed to mimic the built-in `String#center` method, but add support for handling the formatting, since formatting is done by adding non-printing characters to the string. If you were to use the built-in `center` method, you would be adding too little padding. There is also a static version of the method in `EverydayCliUtils::Format` that takes the string as a parameter, for those of you that use the "safe" version. +As of version 1.2.0, there is now support for using color profiles in `String#format_all`. Here's an example: + +```ruby +EverydayCliUtils::Format.color_profile(:p1, bold: true, underline: true, fgcolor: :yellow, bgcolor: :green) +EverydayCliUtils::Format.color_profile(:p2, underline: true, fgcolor: :yellow) +'abc {def}(:p1) ghi {jkl}(:p2) mno'.format_all +``` + +This gives the same result as the earlier example. With color profiles, you define it once and can use it as many times as you want. So if you have an application that lets the user choose colors for certain things, you can define a color profile with the chosen colors once and re-use it as many times as you want. + +Please note that if you define a second color profile with the same id, it will overwrite the first one. + ###EverydayCliUtils::Histogram Create a text-based histogram. This is an extension to the `Enumerable` module, unless you import `:histogram_safe`, in which case you can use the static methods in `EverydayCliUtils::Histogram`, with an added first parameter of the collection. ####Enumerable.histogram(ks = nil, width = 100, height = 50) @@ -247,69 +277,9 @@ ######Parameters * `join_str`: The string to use for joining the elements together. ####Hash.expand Takes a shorthand hash (like `{ [:a, :b, :c, :d] => '1-4', e: '5' }`) and turns it into a full hash (like `{ a: '1-4', b: '1-4', c: '1-4', d: '1-4', :e => '5' }`) - -###EverydayCliUtils::MyCurses - -Encapsulates the code for dealing with the curses library. - -###Fields: -####MyCurses.headers -An array storing the header lines that will be printed out with `MyCurses.myprints`. - -####MyCurses.bodies -An array storing the body lines that will be printed out with `MyCurses.myprints`. - -####MyCurses.footers -An array storing the footer lines that will be printed out with `MyCurses.myprints`. - -###Methods: - -####MyCurses.new(use\_curses, linesh, linesf) -Initializes the class and sets the basic options. - -######Parameters -* `use_curses`: `true` to use curses, `false` to use `puts` -* `linesh`: the number of header lines -* `linesf`: the number of footer lines - -####MyCurses.clear -Clear the `headers`, `bodies`, and `footers` arrays - -####MyCurses.myprints -Print out all of the lines stored in the `headers`, `bodies`, and `footers` arrays. If `use_curses` is `true`, it will use curses and allow for scrolling. Otherwise, it will just print out all of the lines with `puts` - -####MyCurses.read\_ch -Update the character from the body pad. - -####MyCurses.clear\_ch -Clear out any newline, ENTER, UP, or DOWN characters from the queue. - -####MyCurses.scroll\_iteration -Update the display (including doing any scrolling) and read the next character. - -####MyCurses.header\_live\_append(str) -Append `str` to the header pad immediately and update it. Does not modify the `headers` array. - -######Parameters -* `str`: the string to append - -####MyCurses.body\_live\_append(str) -Append `str` to the body pad immediately and update it. Does not modify the `bodies` array. - -######Parameters -* `str`: the string to append - -####MyCurses.footer\_live\_append(str) -Append `str` to the footer pad immediately and update it. Does not modify the `footers` array. - -######Parameters -* `str`: the string to append - -####MyCurses.dispose -Close out the curses screen if curses was used. ###EverydayCliUtils::Option Some utility methods for the `OptionParser` class.