Git Product home page Git Product logo

terminal's Introduction

Terminal

Language Tag Build Status

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

Installation

Add this to your application's shard.yml:

dependencies:
  terminal:
    github: icyleaf/terminal

Usage

UI

require "terminal"

# Usage for Shell UI
Terminal.message "hello world" # => "hello world"
Terminal.success "well done" # => "\e[32mwell done\e[0m"
Terminal.important "Your password is too easy" # => "\e[33mYour password is too easy\e[0m"
Terminal.error "Invaild username or password" # => "\e[31mInvaild username or password\e[0m"
Terminal.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
command_output INFO magenta color
crash! Terminal::Crash an exception by program itself
user_error! Terminal::UserError an exception by user opertions
shell_error! Terminal::ShellError an exception by run shell command

Shell command

require "terminal"

# Check command result
Terminal.test "crystal" # => true

# Run shell command
Terminal.sh "pwd"
$ pwd
โ–ธ /Users/icyleaf

Enable/Disable color

Terminal.enable_color/Terminal.disable_color

Verbose mode

Set Enviroment TERMINAL_UI_SHOW_TIMESTAMP to 1/true

Terminal.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, Logger::Formatter.new { |severity, datetime, progname, message, io|
  io << "VERBOSE" << datetime.to_s("%F") << message
})

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

How to Contribute

Your contributions are always welcome! Please submit a pull request or create an issue to add a new question, bug or feature to the list.

All Contributors are on the wall.

You may also like

  • halite - HTTP Requests Client with a chainable REST API, built-in sessions and middlewares.
  • totem - Load and parse a configuration file or string in JSON, YAML, dotenv formats.
  • markd - Yet another markdown parser built for speed, Compliant to CommonMark specification.
  • poncho - A .env parser/loader improved for performance.
  • popcorn - Easy and Safe casting from one type to another.
  • fast-crystal - ๐Ÿ’จ Writing Fast Crystal ๐Ÿ˜ -- Collect Common Crystal idioms.

License

MIT License ยฉ icyleaf

terminal's People

Contributors

icyleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.