warg 0.1.3 → 0.1.4

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/warg.rb +11 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32b9aa5eb2e34d4cad9498e0befaee2e6b0918393cb5843c7e50dea4764f74e1
4
- data.tar.gz: 540df3adc335e5a5a211baa8a8ee87226ae233e8157481dfd6703a3ee018ee83
3
+ metadata.gz: 424f245fa2ac9ae05aff9e1f4c66e9c5a7a9b5660436e0d5d91a5653fc062d44
4
+ data.tar.gz: a8bc6efa101af3b880fb2a5e012f55e8a8b3510180fe33248df0cffa3f54c724
5
5
  SHA512:
6
- metadata.gz: 8914b0f531a6b88f72eea6f6bd78459c7aa57ceab3f58d9ca83371ab76cd534ba9bd5a33f607e5ac399412256932354322445554e2f48cdee3e55da054dce0fa
7
- data.tar.gz: ad41bbea8f475eddb3c255d1bc19498bc2510a471af4fd5f27598cf15fc3926cb9827a4995010c6e3e3684ae46524cb41a25d7ef31d8371f33d50e16e3b94b73
6
+ metadata.gz: 97c01e3dfdf6df8786a91ba9532917bf3a9e270256eea18bf0cb33e2754fad957403ab9139072bb69ff1a0d6cfbcd082bbdf8cd017916531eb6846bd1fadb986
7
+ data.tar.gz: fd3d3247c2635dded91bfe9fb954a3d18fe55a6b789656e50b593579b069621421da7e6ddb339bb87ea9585604e27556bb4ca97dd890d6069b66e01f716882b0
data/lib/warg.rb CHANGED
@@ -742,7 +742,7 @@ module Warg
742
742
  build_uri!
743
743
  end
744
744
 
745
- def matches?(filters)
745
+ def matches?(**filters)
746
746
  filters.all? do |name, value|
747
747
  if respond_to?(name)
748
748
  send(name) == value
@@ -1349,6 +1349,7 @@ module Warg
1349
1349
 
1350
1350
  class Context < Config
1351
1351
  attr_reader :argv
1352
+ attr_reader :filters
1352
1353
  attr_reader :parser
1353
1354
  attr_reader :playlist
1354
1355
 
@@ -1356,16 +1357,24 @@ module Warg
1356
1357
  @argv = argv
1357
1358
  @playlist = playlist
1358
1359
  @parser = OptionParser.new
1360
+ @filters = {}
1359
1361
 
1360
1362
  @parser.on("-t", "--target HOSTS", Array, "hosts to use") do |hosts_data|
1361
1363
  hosts_data.each { |host_data| hosts.add(host_data) }
1362
1364
  end
1363
1365
 
1366
+ @parser.on("-f", "--filter key=value", String, "filters to apply to hosts") do |filter|
1367
+ key, value = filter.split("=", 2)
1368
+
1369
+ @filters[key] = value
1370
+ end
1371
+
1364
1372
  super()
1365
1373
  end
1366
1374
 
1367
1375
  def parse_options!
1368
1376
  @parser.parse(@argv)
1377
+ @hosts = @hosts.with(**@filters)
1369
1378
  end
1370
1379
 
1371
1380
  def copy(config)
@@ -1450,6 +1459,7 @@ module Warg
1450
1459
 
1451
1460
  def run
1452
1461
  if @command.nil?
1462
+ @context.parse_options!
1453
1463
  $stderr.puts "Could not find command from #{@argv.inspect}"
1454
1464
  exit 1
1455
1465
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Gutierrez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.3.7
196
+ rubygems_version: 3.3.26
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Light-weight interaction with servers