mssh 0.0.4 → 0.0.5

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/mssh +23 -14
  2. metadata +3 -3
data/bin/mssh CHANGED
@@ -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
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mssh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Miller