collins-cli 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/collins/cli/find.rb +11 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d8cb9285558a8adc49d7da521c0241e1331eb08
4
- data.tar.gz: 27559afb065f378b3e60aa010eb3271e40e53222
3
+ metadata.gz: 068a6b925cfcf4b7d3a3d9b637e731186733e88a
4
+ data.tar.gz: 66ab664be91281098cb1c2aba20d249f2a349aa6
5
5
  SHA512:
6
- metadata.gz: b96eda4857aaed7c4a92a704306ff7158f322f3708e24cb66fd15a9665977827d6620fec9244fff7496bf8217445144695d1058e935522504de95fc00f8d50f1
7
- data.tar.gz: 050ca2a0dfddb04dd02c798bcd58fad07078e5445e37f0fb8337360928fb95ea2c7f3518fd293acbeec5da10011296b119b1b4516992adad21f8ec0e8e5b5b1a
6
+ metadata.gz: af1c57c8a001d86e1cb0d2fa0eaf304579785ee29b8f85f46e502b68be644f67bd95cc07b31870ab96339abe2e77bac56d2f248cd97d36ad5f593f13c18d6253
7
+ data.tar.gz: 1b9b927522b57f77650805a549cc01fa3ed99dfac9f71a79ec2b848645cf951798134dafffca42bf6541ec5b411faaa61814a8ca68fc7a0d2a2eb0e4aef3154a
@@ -11,7 +11,7 @@ module Collins::CLI
11
11
  PROG_NAME = 'collins find'
12
12
  QUERY_DEFAULTS = {
13
13
  :operation => 'AND',
14
- :size => 9999,
14
+ :size => 100,
15
15
  }
16
16
  OPTION_DEFAULTS = {
17
17
  :format => :table, # how to display the results
@@ -43,7 +43,7 @@ module Collins::CLI
43
43
  opts.on('-T','--type TYPE',String, "Only show assets with type TYPE") {|v| search_attrs[:type] = v}
44
44
  opts.on('-n','--nodeclass NODECLASS[,...]',Array, "Assets in nodeclass NODECLASS") {|v| search_attrs[:nodeclass] = v}
45
45
  opts.on('-p','--pool POOL[,...]',Array, "Assets in pool POOL") {|v| search_attrs[:pool] = v}
46
- opts.on('-s','--size SIZE',Integer, "Number of assets to return (Default: #{query_opts[:size]})") {|v| query_opts[:size] = v}
46
+ opts.on('-s','--size SIZE',Integer, "Number of assets to return per page (Default: #{query_opts[:size]})") {|v| query_opts[:size] = v}
47
47
  opts.on('-r','--role ROLE[,...]',Array,"Assets in primary role ROLE") {|v| search_attrs[:primary_role] = v}
48
48
  opts.on('-R','--secondary-role ROLE[,...]',Array,"Assets in secondary role ROLE") {|v| search_attrs[:secondary_role] = v}
49
49
  opts.on('-i','--ip-address IP[,...]',Array,"Assets with IP address[es]") {|v| search_attrs[:ip_address] = v}
@@ -90,7 +90,7 @@ module Collins::CLI
90
90
 
91
91
  opts.separator ""
92
92
  opts.separator "Extra options:"
93
- opts.on('--expire SECONDS',Integer,"Timeout in seconds (0 == forever)") {|v| options[:timeout] = v}
93
+ opts.on('--timeout SECONDS',Integer,"Timeout in seconds (0 == forever)") {|v| options[:timeout] = v}
94
94
  opts.on('-C','--config CONFIG',String,'Use specific Collins config yaml for Collins::Client') {|v| options[:config] = v}
95
95
  opts.on('-h','--help',"Help") {options[:mode] = :help}
96
96
 
@@ -145,8 +145,15 @@ _EXAMPLES_
145
145
  if options[:mode] == :help
146
146
  puts parser
147
147
  else
148
+ page = 0
149
+ assets, res = [], []
148
150
  begin
149
- assets = collins.find(query_opts)
151
+ loop do
152
+ res = collins.find(query_opts.merge({:page => page}))
153
+ break if res.empty?
154
+ assets = assets.concat res
155
+ page += 1
156
+ end
150
157
  rescue => e
151
158
  raise "Error querying collins: #{e.message}"
152
159
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collins-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabe Conradi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize