Created
September 5, 2012 09:26
-
-
Save michalbcz/3634032 to your computer and use it in GitHub Desktop.
groovy - simple 'tree' command implementation
This file contains hidden or 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
new File(".").eachDirRecurse { dir -> | |
/* if you wonder why not to write ~/\\/ directly see | |
http://groovy.codehaus.org/Strings+and+GString#StringsandGString-SlashyStringliterals or | |
http://jira.codehaus.org/browse/GROOVY-2451 */ | |
def bs = "\\\\" | |
def fs = "/" | |
def pattern = ~/$bs|$fs/ | |
/* ------------------------------- */ | |
def numberOfDashes = dir.path.findAll(pattern).size() | |
println " " * numberOfDashes + " - " + dir.name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment