13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/patcmd/cli/task_executor.rb', line 13
def execute
command = prepare_command
env_vars = prepare_environment_variables
path = expand_path(@task["path"])
unless Dir.exist?(path)
puts "Path not found: #{path}"
exit(1)
end
puts "Executing '#{@task["description"]}' in #{path}"
puts "Command: #{command}" if @options[:verbose]
puts "Environment Variables: #{env_vars}" if @options[:verbose] && env_vars.any?
Dir.chdir(path) do
result = system(env_vars, command)
unless result
puts "Command execution failed."
exit(1)
end
end
rescue KeyError => e
puts "Missing option for command substitution: #{e.message}"
exit(1)
end
|