Sha256: b07b21af294ee46a699ef7129ee6fc0a0d72329d5714e21c518322a064ae3900
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require "colored" require "active_support/core_ext/module/delegation" require "highline" require "tty-prompt" require "os" 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' `#{OS.open_file_command} \"#{url}\"` end def title(message) highline.say(message.bold) 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 error(message) say(message.red.bold) exit(false) end def run(command, title: nil) title(title) if title say(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-9.1.1 | lib/cp8_cli/command.rb |
cp8_cli-9.1.0 | lib/cp8_cli/command.rb |
cp8_cli-9.0.3 | lib/cp8_cli/command.rb |