Skip to content

Human-friendly Go module that builds and prints directory trees using ASCII art

License

Notifications You must be signed in to change notification settings

borodean/asciitree

Repository files navigation

Go Reference Codacy Quality Codecov Coverage

asciitree

Human-friendly Go module that builds and prints directory trees using ASCII art.

Installation

go get github.com/borodean/asciitree

Usage

// Build a directory tree representation:
tree := asciitree.NewDir("albums").Add(
  asciitree.NewFile("ONUKA.jpg"),
  asciitree.NewDir("VIDLIK").AddFiles(
    "Svitanok.mp3",
    "Vidlik.mp3",
  ),
  asciitree.NewDir("KOLIR").AddFiles(
    "CEAHC.mp3",
    "ZENIT.mp3",
    "UYAVY (feat. DakhaBrakha).mp3",
    "XASHI.mp3",
  ),
)

// Sort the tree's descendants alphanumerically while placing directories
// before files:
tree.Sort(asciitree.WithDirsFirst(true))

// Print an ASCII art representation of the directory tree:
fmt.Println(tree)

License

MIT.

About

Human-friendly Go module that builds and prints directory trees using ASCII art

Resources

License

Stars

Watchers

Forks

Packages

No packages published