Skip to content

list-directory-tree

List the contents of a directory as an indented tree.

Category: Read-only

Parameters

path (required)
The directory to list. Must be absolute; relative paths are resolved against the current working directory.
depth (optional)
How many levels below the root to expand. 0 shows immediate children only; 1 shows children and their children; and so on. Defaults to 3.

Output

An indented plain-text tree. Directories have a trailing /. Entries within each directory are sorted alphabetically:

my-project/
  build/
    libs/
      knosh-all.jar
  src/
    main/
      kotlin/
    test/
      kotlin/
  build.gradle.kts
  settings.gradle.kts

Fails if the path does not exist, is not a directory, or depth is negative.