Skip to content

A Simple DSL to create Directory Tree with Text Files

License

Notifications You must be signed in to change notification settings

kdabir/directree

Repository files navigation

DirecTree

A Simple DSL for :

  • Creating directory trees with text files (with contents).
  • Keeping multiple source directories in sync with a target directory.

Build

directree is available in jcenter maven repository.

@Grab('io.github.kdabir.directree:directree:0.3.2')
import static directree.DirTree.create

create("my-dir") {
    dir ("todo") {
        file "first.txt", "check out this new library"
    }

    file ("README.md") { """
        Directree
        ${'='*80}

        There are multiple ways in which content can be written to a file.
        after all, its all a valid groovy code.
        """.stripIndent()
    }
}

Verifying it:

$ tree my-dir

my-dir
|-- README.md
`-- todo
    `-- first.txt

1 directory, 2 files

$ cat my-dir/README.md

Directree
================================================================================

There are multiple ways in which content can be written to a file.
after all, its all a valid groovy code.

$ cat my-dir/todo/first.txt

check out this new library

More realistic example

You can create a project structure:

create("my-project") {
    dir "src" , {
        file "hello.groovy", "println 'hello world'"
    }
    dir "test", {
        file ".gitkeep"
    }
    file "build.gradle" , ""
    file ".gitignore", "*.class"
}

create(".") will create the files and directories in current directory.

About

A Simple DSL to create Directory Tree with Text Files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages