Sha256: 7be01d8aa4154f3b69b14c2a88114e22923b220b28fbb39f5770358fea234a9b

Contents?: true

Size: 312 Bytes

Versions: 3

Compression:

Stored size: 312 Bytes

Contents

#! /usr/bin/env ruby

require 'xp'

input = STDIN.read.to_nokogiri

$options = ARGV.select{ |o| o =~ /^\-/ }

def text_flag?
  $options.any?{|o| ["-t", "--text"].include?(o) }
end

query = (ARGV - $options).first

output = input.css(query).map do |element|
  text_flag? ? element.text : element
end

puts output

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xp-2.0.2 bin/xp
xp-2.0.1 bin/xp
xp-2.0.0 bin/xp