mandy 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/mandy-local +27 -4
  2. metadata +1 -1
@@ -1,9 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'ostruct'
4
+ require 'cgi'
2
5
 
3
- if ARGV.size==0
4
- puts "USAGE: mandy-local my_script.rb local_input_file local_output_folder"
5
- exit
6
- end
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]))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Kent