go_run 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/go_run.rb +18 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9988225c09ce3743832a8caf4fdd6aee87159150
4
- data.tar.gz: b9eff09dc56eeceb496ca0192728fcca5a9a9c10
3
+ metadata.gz: 4a32e5d4f7388ea7d6f91386c02111d9ade5294f
4
+ data.tar.gz: 4c02c83d1a8d558a331a4818d413402280aef5bd
5
5
  SHA512:
6
- metadata.gz: 153fd74b86a8a62f6ef7a0d111c44b98c837dc1b112541db278aaa3d52d3529f6f9b826fd323c2dca3ff061599558fc5f74c01e5d273771c43559fe0a46b4fab
7
- data.tar.gz: f3baf4092391b8be45f7bfe3958e542b3e1ff47c1d405b6a3de9e712ad36c6e18d5e067ca71f69b88515931d759ba0f2d6a23c86aac3fbf1a09fa4f6b30ae6e2
6
+ metadata.gz: 8406e344af9402065de242dd3eeb61128ecee1bc6608f1287f604e3185f7a42c59e8f2df4972a8c8b394294bf21cf0a5b48c150384bcfb3e1d695e7fd0ea651d
7
+ data.tar.gz: 52d558b52684217030ddf6473c12ef1b54dfa26017e9758abd98ef699cd89121c2f56493b1573c159b4c8f96ff49110d4bf38e8d8147a12dd1a93a11c2b20cb0
@@ -5,28 +5,36 @@ require 'ostruct'
5
5
 
6
6
  class GoRun
7
7
  def initialize(args)
8
- @options = parse_args(args)
8
+ parse_args(args)
9
9
  validate_runfile
10
10
  validate_args
11
11
  run
12
12
  end
13
13
 
14
14
  def parse_args(args)
15
- options = OpenStruct.new
16
- options.runfile = File.expand_path("./Runfile.yml", `pwd`.strip)
17
- opt_parser = OptionParser.new do |opts|
15
+ @options = OpenStruct.new
16
+ @options.runfile = File.expand_path("./Runfile.yml", `pwd`.strip)
17
+ @opt_parser = OptionParser.new do |opts|
18
+ opts.banner = "Usage: #{$0} [options] target [target ...]"
19
+
18
20
  opts.on("-r", "--runfile RUNFILE_PATH",
19
21
  "Set the location of the Runfile") do |runfile|
20
- options.runfile = runfile
22
+ @options.runfile = runfile
23
+ end
24
+
25
+ opts.on_tail("-h", "--help", "Show this message") do |runfile|
26
+ puts opts
27
+ exit 0
21
28
  end
22
29
  end
23
- opt_parser.parse!(args)
24
- options
30
+ @opt_parser.parse!(args)
25
31
  end
26
32
 
27
33
  def validate_runfile
28
34
  if not runfile_exists?
29
35
  puts "Runfile not found: #{@options.runfile}"
36
+ puts
37
+ puts @opt_parser.help()
30
38
  exit 1
31
39
  end
32
40
  end
@@ -37,18 +45,13 @@ class GoRun
37
45
 
38
46
  def validate_args
39
47
  if ARGV.length == 0
40
- print_usage
48
+ puts "You must choose at least one target"
49
+ puts
50
+ puts @opt_parser.help()
41
51
  exit 1
42
52
  end
43
53
  end
44
54
 
45
- def print_usage
46
- puts "You must choose at least one target"
47
- puts
48
- puts "Example usage:"
49
- puts "#{$0} <target> [targets]..."
50
- end
51
-
52
55
  def run
53
56
  runner = Runner.new(Parser.new(@options.runfile).config)
54
57
  runner.run(ARGV)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_run
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Knott