Created
December 20, 2012 12:43
-
-
Save jsakamoto/4345099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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