Skip to content

Instantly share code, notes, and snippets.

@meijeru
Last active January 23, 2018 12:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meijeru/6c8bf306e34fbbf3339721643d378d63 to your computer and use it in GitHub Desktop.
Save meijeru/6c8bf306e34fbbf3339721643d378d63 to your computer and use it in GitHub Desktop.
Count the number of lines of code in the Red source files
Rebol []
red-source: %/C/Users/Eigenaar/Projects/Red/sources/ ; adapt this for your situation
output-sources: %sources.txt
version: read red-source/version.r
vdate: modified? red-source/version.r
nl: "^/"
list-dirs: func [
{***********************************************************************
Recursively check source folders and subfolders for files
***********************************************************************}
pdir [file!] files [block!] indent [string!]
/local ind dir
][
ind: rejoin [indent " "]
sort files
foreach f files [
if #"/" <> last f [
write/lines/append output-sources rejoin [
ind f
copy/part " " 50 - (length? ind) - (length? f)
length? read/lines pdir/:f
]
]
]
foreach f files [
if #"/" = last f [
either any [find f "docs" find f "test"] [
write/lines/append output-sources rejoin [ind f " *"]
][
write/lines/append output-sources rejoin [ind f]
dir: pdir/:f
list-dirs dir read dir ind
]
]
]
]
attempt [delete output-sources]
write/lines/append output-sources "***** Source file hierarchy *****"
write/lines/append output-sources rejoin [
"Red toolchain version " version
" of " vdate/date "/" vdate/time nl
]
write/lines/append output-sources
{file/folder
--------------------------------------------------}
write/lines/append output-sources rejoin [red-source "..."]
list-dirs red-source read red-source "" true
write/lines/append output-sources {
* this directory not considered
-----------------------------------------------------
}
ask "OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment