Class: Sidedock::CLI
- Inherits:
-
Object
- Object
- Sidedock::CLI
- Defined in:
- lib/sidedock/cli.rb
Direct Known Subclasses
Instance Method Summary collapse
- #command_runner ⇒ Object
- #debug_command_runner ⇒ Object
- #execute(command) ⇒ Object
-
#initialize(default_options = '') ⇒ CLI
constructor
A new instance of CLI.
- #quiet_command_runner ⇒ Object
Constructor Details
#initialize(default_options = '') ⇒ CLI
Returns a new instance of CLI.
7 8 9 |
# File 'lib/sidedock/cli.rb', line 7 def initialize( = '') @default_options = end |
Instance Method Details
#command_runner ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/sidedock/cli.rb', line 19 def command_runner if Sidedock.configuration.debug debug_command_runner else quiet_command_runner end end |
#debug_command_runner ⇒ Object
27 28 29 |
# File 'lib/sidedock/cli.rb', line 27 def debug_command_runner @debug_command_runner ||= TTY::Command.new end |
#execute(command) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/sidedock/cli.rb', line 12 def execute(command) full_command = "#{program} #{@default_options} #{command}" stdout, stderr = command_runner.run full_command raise "`#{command}` failed" if stderr.present? stdout.strip end |
#quiet_command_runner ⇒ Object
31 32 33 |
# File 'lib/sidedock/cli.rb', line 31 def quiet_command_runner @quiet_command_runner ||= TTY::Command.new printer: :null end |