terminal

Terminal output styling with intuitive, clean and easy API terminal tty terminal-ui
0.1.1 released

💎 terminal-ui

Tag Dependency Status devDependency Status Build Status License

Terminal output styling with intuitive, clean and easy API written by Crystal.

Installation

Add this to your application's shard.yml:

dependencies:
  terminal-ui:
    github: icyleaf/terminal-ui.cr

Usage

require "terminal/ui"

Terminal::UI.message "hello world" # => "hello world"
Terminal::UI.success "well done" # => "\e[32mwell done\e[0m"
Terminal::UI.important "Your password is too easy" # => "\e[33mYour password is too easy\e[0m"
Terminal::UI.error "Invaild username or password" # => "\e[31mInvaild username or password\e[0m"
Terminal::UI.command "crystal version" # => "\e[36m$ crystal version\e[0m"

Methods

Full methods below:

method | level | description ---|---|--- header | INFO | normal default color with table border (Not compatible with emoji)
+-----+
|Install|
+-----+ message | INFO | normal default color success | INFO | green color important | WARN | yellow color error | ERROR | red color verbose | DEBUG | normal default color deprecated | WARN | blue with bold color command | INFO | cyan color crash | Exception | normal default color

Enable/Disable color

Terminal::UI.enable_color/Terminal::UI.disable_color

Verbose mode

Set Enviroment TERMINAL_UI_SHOW_TIMESTAMP to 1/true

Terminal::UI.success "Installed successful"
# => "INFO 2017-10-22 12:45:33 \e[32mInstalled successful\e[0m"

Adviances

All the output based on Logger, Here support one way to custom the given io and logger formatter.

io = IO::Memory.new
Terminal::UI.logger_io(io, Logger::Formatter.new { |severity, datetime, progname, message, io|
  io << "VERBOSE" << datetime.to_s("%F") << message
})

Terminal::UI.message "Welcome to use terminal-ui"
# => "VERBOSE 2017-10-22 Welcome to use terminal-ui"

Contributing

  1. Fork it ( https://github.com/icyleaf/terminal-ui.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

terminal:
  github: icyleaf/terminal-ui.cr
  version: ~> 0.1.1
License MIT
Crystal 0.25.0

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently