1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

M #-: Add --subtree to xpath.rb (#41)

This commit is contained in:
Jan Orel 2020-06-24 16:35:43 +02:00 committed by GitHub
parent 3681055a5d
commit b9092758e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,17 +26,21 @@ require 'pp'
opts = opts = GetoptLong.new(
[ '--stdin', '-s', GetoptLong::NO_ARGUMENT ],
[ '--subtree', '-t', GetoptLong::NO_ARGUMENT ],
[ '--base64', '-b', GetoptLong::REQUIRED_ARGUMENT ]
)
source = :stdin
tmp64 = ""
subtree = false
begin
opts.each do |opt, arg|
case opt
when '--stdin'
source = :stdin
when '--subtree'
subtree = true
when '--base64'
source = :b64
tmp64 = arg
@ -65,10 +69,10 @@ ARGV.each do |xpath|
else
element = xml.elements[xpath.dup]
if !element.nil?
if element.class.method_defined?(:text)
values << ( element.text || '' )
else
if subtree
values << ( element.to_s || '' )
else
values << ( element.text || '' )
end
end
end