Class: Blix::Cli::CommandOperation
- Defined in:
- lib/blix/cli/operations/command.rb
Overview
create a file system directory
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(path, command, desc) ⇒ CommandOperation
constructor
A new instance of CommandOperation.
- #run ⇒ Object
- #undo ⇒ Object
Methods inherited from Operation
#describe, describe_all, execute_all, list, new, old_new, #perform, reset!
Constructor Details
#initialize(path, command, desc) ⇒ CommandOperation
Returns a new instance of CommandOperation.
12 13 14 15 16 |
# File 'lib/blix/cli/operations/command.rb', line 12 def initialize(path, command, desc) @path = path @command = command @desc = desc end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
10 11 12 |
# File 'lib/blix/cli/operations/command.rb', line 10 def command @command end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/blix/cli/operations/command.rb', line 10 def path @path end |
Instance Method Details
#description ⇒ Object
18 19 20 |
# File 'lib/blix/cli/operations/command.rb', line 18 def description @desc || "run command: #{command}" end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/blix/cli/operations/command.rb', line 22 def run Dir.chdir(path) do std, err, stat = Open3.capture3("#{command}") unless stat.success? puts "----------------------------------------" puts err puts "----------------------------------------" end end end |
#undo ⇒ Object
33 34 35 |
# File 'lib/blix/cli/operations/command.rb', line 33 def undo end |