Created
January 2, 2015 16:50
-
-
Save melix/e27dce2c23467d47e7f4 to your computer and use it in GitHub Desktop.
Improving CLI mode for Groovy
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
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