Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created November 24, 2008 23:23
Show Gist options
  • Select an option

  • Save tommorris/28689 to your computer and use it in GitHub Desktop.

Select an option

Save tommorris/28689 to your computer and use it in GitHub Desktop.
require 'rexml/document'
# Get command line params
filename = ARGV[0]
username = `whoami`.strip
filename = "/Users/" + username + "/Library/Application\ Support/Cultured\ Code/Things/Database.xml"
unless ARGV[1].nil?
qry = ARGV[1].strip
else
qry = nil
end
# Read in XML file
xmlfile = ''
File.open(filename, "r") { |f| xmlfile = f.read }
# Create Xml Document from file contents
doc = REXML::Document.new xmlfile
REXML::XPath.match(doc, "//object[@type='TODO'][relationship/@idrefs='z108']/attribute[@name='title']/text()").reverse.each { |val| puts val }
exit
if qry.class != NilClass
if qry == "--inbox" or qry == "-i"
REXML::XPath.match(doc, "//object[@type='TODO'][relationship/@idrefs='z118']/attribute[@name='title'][@type='string]/text()").reverse.each { |val|
puts "> #{val}"
}
elsif qry.length != 0
# add to file
end
else
# put next actions
REXML::XPath.match(doc, "//object[@type='TODO'][relationship/@idrefs='z108']/attribute[@name='title'][@type='string]/text()").reverse.each { |val|
puts "> #{val}"
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment