Sha256: ba7ed5382242db66c7189ce491cccc4a2a4f3c67cd41d35f1c8e468d3d108fe4
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require "colored" require "active_support/core_ext/module/delegation" require "highline" require "tty-prompt" module Cp8Cli class Command class << self delegate :open_url, :say, :success, :ask, :title, :error, :run, :read, to: :client attr_accessor :client end self.client = new def open_url(url) return title(url) if ENV['BROWSER'] == 'echo' `open \"#{url}\"` end def say(*args) highline.say(*args) end def success(message) highline.say(message.green.bold) end def ask(message, required: true, default: nil) tty.ask(message, required: required, default: default) end def title(message) highline.say(message.bold) end def error(message) say(message.red.bold) exit(false) end def run(command) title(command) system(command) || error("Error running: #{command}") end def read(command) `#{command}`.strip.presence end private def highline @_highline ||= HighLine.new end def tty @_tty ||= TTY::Prompt.new end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cp8_cli-8.1.0 | lib/cp8_cli/command.rb |
cp8_cli-8.0.1 | lib/cp8_cli/command.rb |
cp8_cli-8.0.0 | lib/cp8_cli/command.rb |