Skip to content
This repository
  • 2 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
37  mssh/bin/mssh
@@ -5,17 +5,20 @@ require 'pp'
5 5
 require 'mcmd'
6 6
 
7 7
 require 'optparse'
  8
+require 'ostruct'
8 9
 options = {
9 10
   :maxflight => 50,
10 11
   :timeout => 60,
11 12
   :global_timeout => 600,
12 13
 }
13 14
 optparse = OptionParser.new do |opts|
14  
-  opts.on('-r', '--range RANGE', 'currently takes a CSV list') do |arg|
  15
+  opts.on('-r', '--range RANGE', 'Requires a configured Range::Client. Use --hostlist if you do not use range') do |arg|
15 16
     options[:range] = arg 
16 17
   end
17  
-  opts.on('-f', '--file FILE', 'List of hostnames in a FILE \
18  
-          use (/dev/stdin) for reading from stdin') do |arg|
  18
+  opts.on('--hostlist x,y,z', Array, 'List of hostnames to execute on') do |arg|
  19
+    options[:hostlist] = arg 
  20
+  end
  21
+  opts.on('-f', '--file FILE', 'List of hostnames in a FILE use (/dev/stdin) for reading from stdin') do |arg|
19 22
     options[:file] = arg 
20 23
   end
21 24
   opts.on('-m', '--maxflight 50', 'How many subprocesses? 50 by default') do |arg|
@@ -42,20 +45,26 @@ end
42 45
 optparse.parse!
43 46
 
44 47
 targets = []
45  
-if (!options[:range].nil?)
46  
-    require 'rangeclient'
47  
-    range = Range::Client.new
48  
-    targets = range.expand options[:range]
49  
-elsif (!options[:file].nil?)
50  
-    targets_fd = File.open(options[:file])
51  
-    targets_fd.read.each { |x| targets << x.chomp }
52  
-else 
53  
-    raise "Error, need -r or -f option" 
  48
+if (options[:range].nil? and options[:file].nil? and options[:hostlist].nil?)
  49
+  raise "Error, need -r or -f or --hostlist option"
54 50
 end
55 51
 
  52
+if (!options[:range].nil?)
  53
+  require 'rangeclient'
  54
+  range = Range::Client.new
  55
+  targets.push *range.expand(options[:range])
  56
+end
  57
+if (!options[:file].nil?)
  58
+  targets_fd = File.open(options[:file])
  59
+  targets_fd.read.each { |x| targets << x.chomp }
  60
+end
  61
+if (!options[:hostlist].nil?)
  62
+  targets.push *options[:hostlist]
  63
+end
56 64
 
57  
-raise "Error, need command to run" if ARGV.size.zero?
58  
-raise "Error, too many arguments" if ARGV.size != 1
  65
+raise "no targets specified. Check your -r, -f or --hostlist inputs" if targets.size.zero?
  66
+raise "need command to run" if ARGV.size.zero?
  67
+raise "too many arguments" if ARGV.size != 1
59 68
 
60 69
 
61 70
 
2  mssh/mssh.gemspec
... ...
@@ -1,7 +1,7 @@
1 1
 # -*- encoding: utf-8 -*-
2 2
 Gem::Specification.new do |s|
3 3
   s.name        = "mssh"
4  
-  s.version     = "0.0.4"
  4
+  s.version     = "0.0.5"
5 5
   s.platform    = Gem::Platform::RUBY
6 6
   s.authors     = ["Evan Miller"]
7 7
   s.email       = ["github@squareup.com"]

No commit comments for this range

Something went wrong with that request. Please try again.