lib/rundock/operation/command.rb in rundock-1.0.1 vs lib/rundock/operation/command.rb in rundock-1.0.2
- old
+ new
@@ -6,11 +6,22 @@
if i.is_a?(Hash)
attributes.merge!(i)
next
end
- backend.run_commands(i, attributes)
+ backend.run_commands(
+ assign_args(i, attributes[:task_args]), attributes
+ )
end
+ end
+
+ private
+
+ def assign_args(cmd, args)
+ return cmd unless args
+ cmd.gsub(/\$#/, args.length.to_s)
+ .gsub(/\$@/, args.join(' '))
+ .gsub(/\$[1-9]*/) { |arg_n| args[arg_n.chars[1..-1].join.to_i - 1] }
end
end
end
end