mandy 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/mandy-local +27 -4
- metadata +1 -1
data/bin/mandy-local
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'cgi'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
options = OpenStruct.new
|
8
|
+
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "USAGE: mandy-local my_script.rb local_input_file local_output_folder [options]"
|
11
|
+
|
12
|
+
opts.on("-v", '--variables name=value', "Pass additional parameters to jobs") do |config|
|
13
|
+
options.cmdenv = config
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-j", '--json {"key":"1 value"}', "Pass JSON encoded parameters to jobs") do |config|
|
17
|
+
options.cmdenv = "json=#{CGI.escape(config)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end.parse!
|
7
25
|
|
8
26
|
require "fileutils"
|
9
27
|
|
@@ -11,6 +29,11 @@ def absolute_path(path)
|
|
11
29
|
path =~ /^\// ? path : File.join(Dir.pwd, path)
|
12
30
|
end
|
13
31
|
|
32
|
+
options.cmdenv.split(' ').each do |pair|
|
33
|
+
key, value = pair.split("=")
|
34
|
+
ENV[key] = value
|
35
|
+
end
|
36
|
+
|
14
37
|
file = absolute_path(ARGV[0])
|
15
38
|
input = absolute_path(ARGV[1])
|
16
39
|
output_folder = FileUtils.mkdir_p(absolute_path(ARGV[2]))
|