lib/aly/app.rb in aly-0.1.1 vs lib/aly/app.rb in aly-0.1.2

- old
+ new

@@ -25,13 +25,13 @@ item['PrivateIP'] = (item['NetworkInterfaces']['NetworkInterface'] || []).map { |ni| ni['PrimaryIpAddress'] }.join(', ') item['PublicIP'] = item['EipAddress']['IpAddress'] || '' item['PublicIP'] = item['PublicIpAddress']['IpAddress'].join(', ') if item['PublicIP'] == '' end - if query = args.first + if query = args.first&.split(',') selected = selected.select do |item| - item.values_at('InstanceId', 'InstanceName', 'PrivateIP', 'PublicIP').compact.any? { |e| e.include?(query) } + item.values_at('InstanceId', 'InstanceName', 'PrivateIP', 'PublicIP').compact.any? { |e| query.any? { |q| e.include?(q) } } end end if options['detail'] puts JSON.pretty_generate(selected) @@ -50,13 +50,13 @@ def eip(*args, **options) raw_out = exec('vpc', 'DescribeEipAddresses', '--PageSize=100') selected = raw_out['EipAddresses']['EipAddress'] - if query = args.first + if query = args.first&.split(',') selected = selected.select do |item| - item.values_at('AllocationId', 'InstanceId', 'InstanceType', 'IpAddress').compact.any? { |e| e.include?(query) } + item.values_at('AllocationId', 'InstanceId', 'InstanceType', 'IpAddress').compact.any? { |e| query.any? { |q| e.include?(q) } } end end if options['detail'] puts JSON.pretty_generate(selected) @@ -97,12 +97,12 @@ selected.each do |lb| lb['Listeners'] = listeners[lb['LoadBalancerId']] || [] end - if query = args.first + if query = args.first&.split(',') selected = selected.select do |lb| - lb.values_at('LoadBalancerId', 'LoadBalancerName', 'Address').compact.any? { |e| e.include?(query) } + lb.values_at('LoadBalancerId', 'LoadBalancerName', 'Address').compact.any? { |e| query.any? { |q| e.include?(q) } } end end if options['detail'] selected.each do |row|