Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Created December 20, 2012 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/4345099 to your computer and use it in GitHub Desktop.
Save jsakamoto/4345099 to your computer and use it in GitHub Desktop.
#r "System.Xml.Linq"
open System
open System.Xml
open System.Xml.Linq
open System.IO
if fsi.CommandLineArgs.Length < 2 then
raise <| new Exception("error: .gan file name not specified.")
let Element name (xelem:XElement) = xelem.Element(XName.Get(name))
let Descendants name (xelem:XElement) = xelem.Descendants(XName.Get(name))
let getAttr name (xelem:XElement) = xelem.Attribute(XName.Get(name)).Value
let setAttr name newValue (xelem:XElement) = xelem.Attribute(XName.Get(name)).Value <- newValue
let path = fsi.CommandLineArgs.[1]
let doc = XDocument.Load(path)
doc.Root
|> Element "tasks"
|> Descendants "task"
|> Seq.filter (getAttr "complete" >> (=) "100")
|> Seq.iter (setAttr "color" "#cccccc")
doc.Save(path);
printfn "Complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment