Skip to content

Instantly share code, notes, and snippets.

@melix
Created January 2, 2015 16:50
Show Gist options
  • Save melix/e27dce2c23467d47e7f4 to your computer and use it in GitHub Desktop.
Save melix/e27dce2c23467d47e7f4 to your computer and use it in GitHub Desktop.
Improving CLI mode for Groovy
class CLICategory {
static Iterator getLines(String f) { new File(f).iterator() }
static int getLength(String s) { s.length() }
static def max(Iterator c,String property) { c.max { it."$property" } }
}
def propertyMissing(String p) { "$p" }
use (CLICategory) {
'quotes.txt'.lines.max length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment