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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b44ddd3 · Jan 3, 2022

History

16 Commits
Jan 3, 2022
Dec 25, 2021
Dec 25, 2021
Dec 26, 2021
Jan 3, 2022
Dec 27, 2021
Dec 27, 2021
Dec 27, 2021
Dec 27, 2021
Dec 26, 2021
Dec 26, 2021
Dec 27, 2021
Dec 27, 2021

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.