Coder Social home page Coder Social logo

rvm2-ui's Introduction

Rvm2::Ui

Gem Version Code Climate Coverage Status Build Status Dependency Status Documentation

Example output

Using :console handler:

[ ] Command 1
  Log output 1
  [x] Command 2
  [ ] Command 3
    Log output 2
  [v] Command 3
[v] Command 1

Installation

Get the gem:

gem install rvm2-ui

Load it:

require 'rvm2/ui'

Usage

Different handlers can be loaded using pluginator group rvm2 type ui/output:

Rvm2::Ui.get(type = :console, rvm2_plugins = nil, *args)

the args will be passed to the handler constructor.

To get the default console output:

@ui = Rvm2::Ui.get

Wrapping code blocks

The command will produce checklist like item:

@ui.command('display name') do do_something end

Example output with :console output - before finish:

[ ] Group 1

after finish:

[v] Group 1

Logging output

The log allows giving messages, warnings and errors to user:

log(message, type = :log)

Supported types are :log, :warn, :warn_important, :error, any other type might be supported or should be handled as :log with the capitalized type as prefix.

Example:

@ui.log("something went wrong", :error)

Would produce with console:

Error: something went wrong

Handling extra outputs

In some cases like running shell commands an stdout and stderr objects are available with IO interface allowing proper output handling (not injecting text in random places):

@ui.command("test") do
  @ui.stderr.puts("debugging output")
end

would produce with :console:

[ ] test
  debugging output
[v] test

Combining multiple outputs

In some cases it might be useful to send the same output to different targets like UI and log:

Rvm2::UI.multi(rvm2_plugins)

Example use:

@ui = Rvm2::UI.multi
@ui.add(:console)
@ui.add(:log, "my_app.log")
@ui.log("text")
@ui.remove # removes the last added logger

Example - temporarily use logger:

@ui = Rvm2::UI.multi
@ui.add(:console)
@ui.with(:log, "my_app.log") do
  @ui.log("text")
end

In both examples the output will be written to both standard output and log file.

rvm2-ui's People

Contributors

mpapis 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.