class Cp8Cli::Command
Attributes
client[RW]
Public Instance Methods
ask(message, required: true, default: nil)
click to toggle source
# File lib/cp8_cli/command.rb, line 33 def ask(message, required: true, default: nil) tty.ask(message, required: required, default: default) end
error(message)
click to toggle source
# File lib/cp8_cli/command.rb, line 37 def error(message) say(message.red.bold) exit(false) end
open_url(url)
click to toggle source
# File lib/cp8_cli/command.rb, line 16 def open_url(url) return title(url) if ENV['BROWSER'] == 'echo' `#{OS.open_file_command} \"#{url}\"` end
read(command)
click to toggle source
# File lib/cp8_cli/command.rb, line 48 def read(command) `#{command}`.strip.presence end
run(command, title: nil)
click to toggle source
# File lib/cp8_cli/command.rb, line 42 def run(command, title: nil) title(title) if title say(command) system(command) || error("Error running: #{command}") end
say(*args)
click to toggle source
# File lib/cp8_cli/command.rb, line 25 def say(*args) highline.say(*args) end
success(message)
click to toggle source
# File lib/cp8_cli/command.rb, line 29 def success(message) highline.say(message.green.bold) end
title(message)
click to toggle source
# File lib/cp8_cli/command.rb, line 21 def title(message) highline.say(message.bold) end
Private Instance Methods
highline()
click to toggle source
# File lib/cp8_cli/command.rb, line 54 def highline @_highline ||= HighLine.new end
tty()
click to toggle source
# File lib/cp8_cli/command.rb, line 58 def tty @_tty ||= TTY::Prompt.new end