CLI Miami
A feature rich alternative for gets
and puts
for your cli interface
gem install cli_miami
Gemfile
# This exposes the shortened API for `A.sk` and `S.ay`
gem 'cli_miami'
# if you need the API to be namespaced (`CliMiami::A.sk`, `CliMiami::S.ay`)
gem 'cli_miami', :require => :namespaced
S.ay
S.ay
accepts 2 arguments, a string, and a variety of options
* see supported options below
S.ay 'Hello World', :color => :red
Sometimes you want to have multiple styles on a single line. There are 2 ways to do this.
The multi-line way using :newline => false
S.ay 'Hello ', :color => :red, :newline => false
S.ay 'World', :color => :blue
Or on a single line using ANSI codes as methods. All the ANSI color and style codes listed below can be used
S.ay "#{'Hello'.red} #{'World'.blue}"
A.sk
A.sk
accepts the same arguments as S.say
, with additional support for a block that passes the users response
A.sk 'What is your name?', :color => :yellow do |response|
S.ay "#{response} smells!", :style => :bold
end
Options
Both S.ay
and A.sk
suport the same options
color: => [symbol] # See ansi color codes below
bgcolor: => [symbol] # See ansi color codes below
style: => [symbol] # See ansi style codes below. Can accept multiple styles as an array
justify: => [center|ljust|rjust] # The type of justification to use
padding: => [integer] # The maximum string size to justify text in
indent: => [integer] # The number of characters to indent
newline: => [boolean] # True if you want a newline after the output
overwrite: => [boolean] # True if you want the next line to overwrite the current line
ANSI Color Codes
:black
:red
:green
:yellow
:blue
:magenta
:cyan
:white
ANSI Style Codes
:bold
:bright
:underline
:negative
Swap foreground color with background color
Development & Testing
yuyi -m https://raw.githubusercontent.com/brewster1134/CLI-Miami/master/yuyi_menu
bundle install
bundle exec guard