Class: Cp8Cli::Command
- Inherits:
- 
      Object
      
        - Object
- Cp8Cli::Command
 
- Defined in:
- lib/cp8_cli/command.rb
Class Attribute Summary collapse
- 
  
    
      .client  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute client. 
Instance Method Summary collapse
- #ask(message, required: true, default: nil) ⇒ Object
- #error(message) ⇒ Object
- #open_url(url) ⇒ Object
- #read(command) ⇒ Object
- #run(command, title: nil) ⇒ Object
- #say(*args) ⇒ Object
- #success(message) ⇒ Object
- #title(message) ⇒ Object
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
| 11 12 13 | # File 'lib/cp8_cli/command.rb', line 11 def client @client end | 
Instance Method Details
#ask(message, required: true, default: nil) ⇒ Object
| 33 34 35 | # File 'lib/cp8_cli/command.rb', line 33 def ask(, required: true, default: nil) tty.ask(, required: required, default: default) end | 
#error(message) ⇒ Object
| 37 38 39 40 | # File 'lib/cp8_cli/command.rb', line 37 def error() say(.red.bold) exit(false) end | 
#open_url(url) ⇒ Object
| 16 17 18 19 | # 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) ⇒ Object
| 48 49 50 | # File 'lib/cp8_cli/command.rb', line 48 def read(command) `#{command}`.strip.presence end | 
#run(command, title: nil) ⇒ Object
| 42 43 44 45 46 | # 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) ⇒ Object
| 25 26 27 | # File 'lib/cp8_cli/command.rb', line 25 def say(*args) highline.say(*args) end | 
#success(message) ⇒ Object
| 29 30 31 | # File 'lib/cp8_cli/command.rb', line 29 def success() highline.say(.green.bold) end | 
#title(message) ⇒ Object
| 21 22 23 | # File 'lib/cp8_cli/command.rb', line 21 def title() highline.say(.bold) end |