Class: Blix::Cli::CommandOperation

Inherits:
Operation
  • Object
show all
Defined in:
lib/blix/cli/operations/command.rb

Overview

create a file system directory

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/blix/cli/operations/command.rb', line 10

def command
  @command
end

#pathObject (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

#descriptionObject



18
19
20
# File 'lib/blix/cli/operations/command.rb', line 18

def description
  @desc || "run command: #{command}"
end

#runObject



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

#undoObject



33
34
35
# File 'lib/blix/cli/operations/command.rb', line 33

def undo

end