{"id":20924743,"url":"https://github.com/ddddddo/gtree","last_synced_at":"2026-02-01T00:11:20.077Z","repository":{"id":38095744,"uuid":"372102795","full_name":"ddddddO/gtree","owner":"ddddddO","description":"Using either Markdown or Programmatically to generate trees🌳 and directories📁, and to verify directories🔍. Provide CLI, Go package and Web.","archived":false,"fork":false,"pushed_at":"2025-04-06T06:32:45.000Z","size":24600,"stargazers_count":289,"open_issues_count":34,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T07:17:49.689Z","etag":null,"topics":["cli","directory","go","go-package","golang","markdown","tree","tree-structure","trees","wasm"],"latest_commit_sha":null,"homepage":"https://ddddddo.github.io/gtree/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddddddO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-30T01:51:22.000Z","updated_at":"2025-04-06T06:32:48.000Z","dependencies_parsed_at":"2023-12-29T11:28:44.707Z","dependency_job_id":"e67fdb57-ece5-4cfb-a789-c00f8ad33fd6","html_url":"https://github.com/ddddddO/gtree","commit_stats":{"total_commits":1089,"total_committers":4,"mean_commits":272.25,"dds":0.06519742883379243,"last_synced_commit":"c326d44a9e17fb927802d973eee72b56e4ab2aa8"},"previous_names":["ddddddo/gentree"],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddddddO%2Fgtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddddddO%2Fgtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddddddO%2Fgtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddddddO%2Fgtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddddddO","download_url":"https://codeload.github.com/ddddddO/gtree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173827,"owners_count":21059594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","directory","go","go-package","golang","markdown","tree","tree-structure","trees","wasm"],"created_at":"2024-11-18T20:24:42.036Z","updated_at":"2026-02-01T00:11:20.070Z","avatar_url":"https://github.com/ddddddO.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"assets/heart-balloon.svg\" width=\"77\"\u003e[^1]\u003cbr\u003e\n[![GitHub Pages](https://img.shields.io/badge/-GitHub_Pages-00A98F.svg?logo=github\u0026style=flat)](https://ddddddo.github.io/gtree/)\u003cbr\u003e\n[![DeepWiki](https://img.shields.io/badge/DeepWiki-ddddddO%2Fgtree-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/ddddddO/gtree)\u003cbr\u003e\n[![GitHub release](https://img.shields.io/github/release/ddddddO/gtree.svg?label=Release\u0026color=darkcyan)](https://github.com/ddddddO/gtree/releases) [![Go Reference](https://pkg.go.dev/badge/github.com/ddddddO/gtree)](https://pkg.go.dev/github.com/ddddddO/gtree)\u003cbr\u003e\n[![License](https://img.shields.io/badge/License-BSD_2--Clause-orange.svg?color=darkcyan)](https://github.com/ddddddO/gtree/blob/master/LICENSE) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#uncategorized)\u003cbr\u003e\n[![codecov](https://codecov.io/gh/ddddddO/gtree/branch/master/graph/badge.svg?token=JLGSLF33RH)](https://codecov.io/gh/ddddddO/gtree) [![Go Report Card](https://goreportcard.com/badge/github.com/ddddddO/gtree)](https://goreportcard.com/report/github.com/ddddddO/gtree) [![ci](https://github.com/ddddddO/gtree/actions/workflows/ci.yaml/badge.svg)](https://github.com/ddddddO/gtree/actions/workflows/ci.yaml)\n\nEasily output ASCII tree from Go program or Markdown unordered list (and it does more than just output tree!🌳🗂🔍)\n\n# Table of Contents\n- Features\n\t- Package - **[Programmable tree structure](https://github.com/ddddddO/gtree?tab=readme-ov-file#package---programmable-tree-structure)**\n\t\t- Recommended for developers!👍\n\t\t- **[Acknowledgments](https://github.com/ddddddO/gtree?tab=readme-ov-file#acknowledgments)**\n\t- Package - **[Markdown to tree structure](https://github.com/ddddddO/gtree?tab=readme-ov-file#package---markdown-to-tree-structure)**\n\t- **[Web](https://github.com/ddddddO/gtree?tab=readme-ov-file#web)**\n\t- **[CLI](https://github.com/ddddddO/gtree?tab=readme-ov-file#cli)**\n- [Documents](https://github.com/ddddddO/gtree?tab=readme-ov-file#documents)\n- [Process](https://github.com/ddddddO/gtree?tab=readme-ov-file#process)\n- [Performance](https://github.com/ddddddO/gtree?tab=readme-ov-file#performance)\n- [Contributing](https://github.com/ddddddO/gtree?tab=readme-ov-file#contributing)\n- [Test coverage](https://github.com/ddddddO/gtree?tab=readme-ov-file#test-coverage)\n\n# Package - Programmable tree structure\n\n\u003e [!NOTE]\n\u003e There are sample repositories that use gtree package.\u003cbr\u003e\n\u003e See [here](https://github.com/ddddddO/gtree/blob/master/example/README.md) for details.\n\n## Simple example\n\nI urge you to run this program. This package is probably the easiest Go package to output tree.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/ddddddO/gtree\"\n)\n\nfunc main() {\n\tvar root *gtree.Node = gtree.NewRoot(\"root\")\n\troot.Add(\"child 1\").Add(\"child 2\").Add(\"child 3\")\n\tvar child4 *gtree.Node = root.Add(\"child 1\").Add(\"child 2\").Add(\"child 4\")\n\tchild4.Add(\"child 5\")\n\tchild4.Add(\"child 6\").Add(\"child 7\")\n\troot.Add(\"child 8\")\n\tif err := gtree.OutputFromRoot(os.Stdout, root); err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n\t// Output:\n\t// root\n\t// ├── child 1\n\t// │   └── child 2\n\t// │       ├── child 3\n\t// │       └── child 4\n\t// │           ├── child 5\n\t// │           └── child 6\n\t// │               └── child 7\n\t// └── child 8\n}\n```\n\n## Installation\n\nGo version requires 1.24 or later.\n\n```console\n$ go get github.com/ddddddO/gtree\n```\n\n## Usage\n\n|Function|Description|Available optional functions|\n|--|--|--|\n|*[OutputFromRoot](https://pkg.go.dev/github.com/ddddddO/gtree#OutputFromRoot)*|can output tree|WithMidBranch\u003cbr\u003eWithLastBranch\u003cbr\u003eWithVLine\u003cbr\u003eWithHLine\u003cbr\u003eWithEncodeJSON\u003cbr\u003eWithEncodeTOML\u003cbr\u003eWithEncodeYAML|\n|*[MkdirFromRoot](https://pkg.go.dev/github.com/ddddddO/gtree#MkdirFromRoot)*|can create directories|WithTargetDir\u003cbr\u003eWithFileExtensions\u003cbr\u003eWithDryRun|\n|*[VerifyFromRoot](https://pkg.go.dev/github.com/ddddddO/gtree#VerifyFromRoot)*|can output the difference between tree you composed and directories|WithTargetDir\u003cbr\u003eWithStrictVerify|\n|*[WalkFromRoot](https://pkg.go.dev/github.com/ddddddO/gtree#WalkFromRoot)*|can execute user-defined function while traversing tree structure recursively|WithMidBranch\u003cbr\u003eWithLastBranch\u003cbr\u003eWithVLine\u003cbr\u003eWithHLine|\n|*[WalkIterFromRoot](https://pkg.go.dev/github.com/ddddddO/gtree#WalkIterFromRoot)*|it returns each node resulting from a recursive traversal of the tree structure, so you can process on each node|WithMidBranch\u003cbr\u003eWithLastBranch\u003cbr\u003eWithVLine\u003cbr\u003eWithHLine|\n\n\u003e [!TIP]\n\u003e Specifying ***WithDuplicationAllowed*** function in ***NewRoot*** function,\n\u003e which generates the Node arguments for the above functions,\n\u003e allows multiple nodes with the same text to exist within the same hierarchy.\n\n### Standard Pattern and Pattern Allowing Node Duplication\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/ddddddO/gtree\"\n)\n\nfunc main() {\n\trootOfStandard := gtree.NewRoot(\"Standard Pattern\")\n\taddChildren(rootOfStandard)\n\t_ = gtree.OutputFromRoot(os.Stdout, rootOfStandard)\n\t// Standard Pattern\n\t// ├── child 1\n\t// │   └── child 2\n\t// │       ├── child 3\n\t// │       └── child 4\n\t// │           ├── child 5\n\t// │           └── child 6\n\t// │               ├── child 7\n\t// │               └── child 9\n\t// └── child 8\n\n\trootOfAllowedDuplication := gtree.NewRoot(\"Pattern Allowing Node Duplication\", gtree.WithDuplicationAllowed())\n\taddChildren(rootOfAllowedDuplication)\n\t_ = gtree.OutputFromRoot(os.Stdout, rootOfAllowedDuplication)\n\t// Pattern Allowing Node Duplication\n\t// ├── child 1\n\t// │   └── child 2\n\t// │       └── child 3\n\t// ├── child 1\n\t// │   └── child 2\n\t// │       └── child 4\n\t// │           ├── child 5\n\t// │           ├── child 6\n\t// │           │   └── child 7\n\t// │           ├── child 6\n\t// │           │   └── child 9\n\t// │           └── child 5\n\t// └── child 8\n}\n\nfunc addChildren(root *gtree.Node) {\n\troot.Add(\"child 1\").Add(\"child 2\").Add(\"child 3\")\n\tvar child4 *gtree.Node = root.Add(\"child 1\").Add(\"child 2\").Add(\"child 4\")\n\tchild4.Add(\"child 5\")\n\tchild4.Add(\"child 6\").Add(\"child 7\")\n\tchild4.Add(\"child 6\").Add(\"child 9\")\n\tchild4.Add(\"child 5\")\n\troot.Add(\"child 8\")\n}\n```\n\n## Acknowledgments\n\n### Thanks for providing very useful CLI for cloud storage tree output🤩🎉\n\nEveryone is encouraged to use them!\n\n#### ⭐[_orangekame3/stree_](https://github.com/orangekame3/stree)\nCLI for **Amazon S3** tree output.\u003c/br\u003e\n[_aws s3_](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/index.html) command does not do what `tree` command does, but [**_stree_**](https://github.com/orangekame3/stree) command can display tree!\n\n#### ⭐[_owlinux1000/gcstree_](https://github.com/owlinux1000/gcstree)\nCLI for **Google Cloud Storage** tree output.\u003c/br\u003e\n[_gcloud storage_](https://cloud.google.com/sdk/gcloud/reference/storage) command does not do what `tree` command does, but [**_gcstree_**](https://github.com/owlinux1000/gcstree) command can display tree!\n\n### gtree packeage has been utilized for other tools as well🚀\nI hope you will use these tools as well!\n\n- [Tools](https://github.com/ddddddO/gtree/network/dependents)\n\n# Package - Markdown to tree structure\n\n## Installation\n\nGo version requires 1.24 or later.\n\n```console\n$ go get github.com/ddddddO/gtree\n```\n\n## Usage\n\nThe symbols that can be used in Markdown are `*`, `-`, `+`, and `#`.\n\n|Function|Description|Available optional functions|\n|--|--|--|\n|*[OutputFromMarkdown](https://pkg.go.dev/github.com/ddddddO/gtree#OutputFromMarkdown)*|can output trees|WithMidBranch\u003cbr\u003eWithLastBranch\u003cbr\u003eWithVLine\u003cbr\u003eWithHLine\u003cbr\u003eWithEncodeJSON\u003cbr\u003eWithEncodeTOML\u003cbr\u003eWithEncodeYAML\u003cbr\u003eWithMassive|\n|*[MkdirFromMarkdown](https://pkg.go.dev/github.com/ddddddO/gtree#MkdirFromMarkdown)*|can create directories|WithTargetDir\u003cbr\u003eWithFileExtensions\u003cbr\u003eWithDryRun\u003cbr\u003eWithMassive|\n|*[VerifyFromMarkdown](https://pkg.go.dev/github.com/ddddddO/gtree#VerifyFromMarkdown)*|can output the difference between markdown and directories|WithTargetDir\u003cbr\u003eWithStrictVerify\u003cbr\u003eWithMassive|\n|*[WalkFromMarkdown](https://pkg.go.dev/github.com/ddddddO/gtree#WalkFromMarkdown)*|can execute user-defined function while traversing tree structure recursively|WithMidBranch\u003cbr\u003eWithLastBranch\u003cbr\u003eWithVLine\u003cbr\u003eWithHLine\u003cbr\u003eWithMassive|\n\n# Web\n\nhttps://ddddddo.github.io/gtree/\n\nThis page is that converts from Markdown to tree!\u003cbr\u003e\nThis page calls a function that outputs tree. This function is a Go package compiled as WebAssembly.\u003cbr\u003e\nThe symbols that can be used in Markdown are `*`, `-`, `+`, and `#`.\u003cbr\u003e\nIndentation represents hierarchy. The indentation can be whatever you specify, but use the same pattern.\u003cbr\u003e\nYou can change the branches like in the image below.\u003cbr\u003e\nAlso, once loaded, you can enjoy offline!\u003cbr\u003e\n\n![](assets/web_example.gif)\n\nYou can open it in your browser with\n```console\n$ gtree web\n```\n\n[source code](cmd/gtree-wasm/)\n\n\n# CLI\n\n\u003cimg src=\"assets/demo.gif\"\u003e\u003cbr\u003e\n\n## Installation\n\n\u003cpre\u003e\n\u003cb\u003eGo\u003c/b\u003e\n$ go install github.com/ddddddO/gtree/cmd/gtree@latest\n\n\u003ca href=\"https://github.com/aquaproj/aqua-registry/blob/main/pkgs/ddddddO/gtree/pkg.yaml\"\u003e\u003cb\u003eaqua\u003c/b\u003e\u003c/a\u003e\n$ aqua g -i ddddddO/gtree\n\n\u003ca href=\"https://github.com/Homebrew/homebrew-core/blob/master/Formula/g/gtree.rb\"\u003e\u003cb\u003eHomebrew\u003c/b\u003e\u003c/a\u003e\n$ brew install gtree\n\n\u003ca href=\"https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/gt/gtree/package.nix\"\u003e\u003cb\u003eNix\u003c/b\u003e\u003c/a\u003e\n$ nix-env -i gtree\nor\n$ nix-shell -p gtree\n\n\u003ca href=\"https://github.com/macports/macports-ports/blob/master/sysutils/gtree/Portfile\"\u003e\u003cb\u003eMacPorts\u003c/b\u003e\u003c/a\u003e\n$ port install gtree\n\n\u003cs\u003e\u003ca href=\"https://aur.archlinux.org/packages/gtree\"\u003e\u003cb\u003eAUR\u003c/b\u003e\u003c/a\u003e\u003c/s\u003e\n$ wip...\n\n\u003cb\u003eScoop\u003c/b\u003e\n$ scoop bucket add ddddddO https://github.com/ddddddO/scoop-bucket.git\n$ scoop install ddddddO/gtree\n\n\u003cb\u003edeb\u003c/b\u003e\n$ export GTREE_VERSION=X.X.X\n$ curl -o gtree.deb -L https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.deb\n$ dpkg -i gtree.deb\n\n\u003cb\u003erpm\u003c/b\u003e\n$ export GTREE_VERSION=X.X.X\n$ yum install https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.rpm\n\n\u003cb\u003eapk\u003c/b\u003e\n$ export GTREE_VERSION=X.X.X\n$ curl -o gtree.apk -L https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.apk\n$ apk add --allow-untrusted gtree.apk\n\n\u003ca href=\"https://github.com/ddddddO/gtree/pkgs/container/gtree\"\u003e\u003cb\u003eDocker\u003c/b\u003e\u003c/a\u003e\n$ docker pull ghcr.io/ddddddo/gtree:latest\n$ docker run ghcr.io/ddddddo/gtree:latest template | docker run -i ghcr.io/ddddddo/gtree:latest output\ngtree\n├── cmd\n│   └── gtree\n│       └── main.go\n├── testdata\n│   ├── sample1.md\n│   └── sample2.md\n├── Makefile\n└── tree.go\n\u003c/pre\u003e\n\n### etc\n\n**download binary from [here](https://github.com/ddddddO/gtree/releases).**\n\n## Usage\n\n```console\n$ gtree --help\nNAME:\n   gtree - This CLI uses Markdown to generate directory trees and directories itself, and also verifies directories.\n           The symbols that can be used in Markdown are '-', '+', '*', and '#'.\n           Within Markdown, indentation represents hierarchy. The indentation can be whatever you specify, but use the same pattern.\n\nUSAGE:\n   gtree [global options] command [command options] [arguments...]\n\nVERSION:\n   1.10.2 / revision 85520a1\n\nCOMMANDS:\n   output, o, out     Outputs tree from markdown.\n                      Let's try 'gtree template | gtree output'.\n   mkdir, m           Makes directories and files from markdown. It is possible to dry run.\n                      Let's try 'gtree template | gtree mkdir -e .go -e .md -e Makefile'.\n   verify, vf         Verifies tree structure represented in markdown by comparing it with existing directories.\n                      Let's try 'gtree template | gtree verify'.\n   template, t, tmpl  Outputs markdown template. Use it to try out gtree CLI.\n   web, w, www        Opens \"Tree Maker\" in your browser and shows the URL in terminal.\n   version, v         Prints the version.\n   help, h            Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --help, -h     show help\n   --version, -v  print the version\n```\n\n### *Output* subcommand\n```console\n$ gtree output --help\nNAME:\n   gtree output - Outputs tree from markdown.\n                  Let's try 'gtree template | gtree output'.\n\nUSAGE:\n   gtree output [command options] [arguments...]\n\nOPTIONS:\n   --file value, -f value               specify the path to markdown file. (default: stdin)\n   --massive, -m                        set this option when there are very many blocks of markdown. (default: false)\n   --massive-timeout value, --mt value  set this option if you want to set a timeout. (default: 0s)\n   --format value                       set this option when specifying output format. \"json\", \"yaml\", \"toml\"\n   --watch, -w                          follow changes in markdown file. (default: false)\n   --help, -h                           show help\n```\n\n#### Try it!\n\n```console\n$ gtree template\n- gtree\n        - cmd\n                - gtree\n                        - main.go\n        - testdata\n                - sample1.md\n                - sample2.md\n        - Makefile\n        - tree.go\n$ gtree template | gtree output\ngtree\n├── cmd\n│   └── gtree\n│       └── main.go\n├── testdata\n│   ├── sample1.md\n│   └── sample2.md\n├── Makefile\n└── tree.go\n```\n\nOther pattern.\n\n```\n├── gtree output -f testdata/sample1.md\n├── cat testdata/sample1.md | gtree output -f -\n└── cat testdata/sample1.md | gtree output\n```\n\n\n#### Usage other than representing a directory.\n\n```console\n$ cat testdata/sample2.md | gtree output\nk8s_resources\n├── (Tier3)\n│   └── (Tier2)\n│       └── (Tier1)\n│           └── (Tier0)\n├── Deployment\n│   └── ReplicaSet\n│       └── Pod\n│           └── container(s)\n├── CronJob\n│   └── Job\n│       └── Pod\n│           └── container(s)\n└── (empty)\n    ├── DaemonSet\n    │   └── Pod\n    │       └── container(s)\n    └── StatefulSet\n        └── Pod\n            └── container(s)\n```\n\n\n#### Multiple roots\n\n```console\n$ cat testdata/sample6.md | gtree output\nArtiodactyla\n├── Artiofabula\n│   ├── Cetruminantia\n│   │   ├── Whippomorpha\n│   │   │   ├── Hippopotamidae\n│   │   │   └── Cetacea\n│   │   └── Ruminantia\n│   └── Suina\n└── Tylopoda\nCarnivora\n├── Feliformia\n└── Caniformia\n    ├── Canidae\n    └── Arctoidea\n        ├── Ursidae\n        └── x\n            ├── Pinnipedia\n            └── Musteloidea\n                ├── Ailuridae\n                └── x\n                    ├── Mephitidae\n                    └── x\n                        ├── Procyonidae\n                        └── Mustelidae\n```\n\n#### Output JSON\n\n\u003cdetails\u003e\u003csummary\u003esee\u003c/summary\u003e\n\n```console\n$ cat testdata/sample5.md | gtree output --format json | jq\n{\n  \"value\": \"a\",\n  \"children\": [\n    {\n      \"value\": \"i\",\n      \"children\": [\n        {\n          \"value\": \"u\",\n          \"children\": [\n            {\n              \"value\": \"k\",\n              \"children\": null\n            },\n            {\n              \"value\": \"kk\",\n              \"children\": null\n            }\n          ]\n        },\n        {\n          \"value\": \"t\",\n          \"children\": null\n        }\n      ]\n    },\n    {\n      \"value\": \"e\",\n      \"children\": [\n        {\n          \"value\": \"o\",\n          \"children\": null\n        }\n      ]\n    },\n    {\n      \"value\": \"g\",\n      \"children\": null\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n#### Output YAML\n\n\u003cdetails\u003e\u003csummary\u003esee\u003c/summary\u003e\n\n```console\n$ cat testdata/sample5.md | gtree output --format yaml\nvalue: a\nchildren:\n- value: i\n  children:\n  - value: u\n    children:\n    - value: k\n      children: []\n    - value: kk\n      children: []\n  - value: t\n    children: []\n- value: e\n  children:\n  - value: o\n    children: []\n- value: g\n  children: []\n```\n\n\u003c/details\u003e\n\n#### Output TOML\n\n\u003cdetails\u003e\u003csummary\u003esee\u003c/summary\u003e\n\n```console\n$ cat testdata/sample5.md | gtree output --format toml\nvalue = 'a'\n[[children]]\nvalue = 'i'\n[[children.children]]\nvalue = 'u'\n[[children.children.children]]\nvalue = 'k'\nchildren = []\n[[children.children.children]]\nvalue = 'kk'\nchildren = []\n\n[[children.children]]\nvalue = 't'\nchildren = []\n\n[[children]]\nvalue = 'e'\n[[children.children]]\nvalue = 'o'\nchildren = []\n\n[[children]]\nvalue = 'g'\nchildren = []\n\n```\n\n\u003c/details\u003e\n\n\n### *Mkdir* subcommand\n\n```console\n$ gtree mkdir --help\nNAME:\n   gtree mkdir - Makes directories and files from markdown. It is possible to dry run.\n                 Let's try 'gtree template | gtree mkdir -e .go -e .md -e Makefile'.\n\nUSAGE:\n   gtree mkdir [command options] [arguments...]\n\nOPTIONS:\n   --file value, -f value                                       specify the path to markdown file. (default: stdin)\n   --dry-run, -d                                                dry run. detects node that is invalid for directory generation. the order of the output and made directories does not always match. (default: false)\n   --extension value, -e value [ --extension value, -e value ]  set this option if you want to create file instead of directory. for example, if you want to generate files with \".go\" extension: \"-e .go\"\n   --target-dir value                                           set this option if you want to specify the directory you want to make directory. (default: current directory)\n   --help, -h                                                   show help\n```\n\n#### Try it!\n\n```console\n$ gtree template\n- gtree\n        - cmd\n                - gtree\n                        - main.go\n        - testdata\n                - sample1.md\n                - sample2.md\n        - Makefile\n        - tree.go\n$ gtree template | gtree mkdir\n$ tree gtree/\ngtree/\n├── cmd\n│   └── gtree\n│       └── main.go\n├── Makefile\n├── testdata\n│   ├── sample1.md\n│   └── sample2.md\n└── tree.go\n\n8 directories, 0 files\n```\n\n#### *make directories and files*\n```console\n$ gtree template\n- gtree\n        - cmd\n                - gtree\n                        - main.go\n        - testdata\n                - sample1.md\n                - sample2.md\n        - Makefile\n        - tree.go\n$ gtree template | gtree mkdir -e .go -e .md -e Makefile\n$ tree gtree/\ngtree/\n├── cmd\n│   └── gtree\n│       └── main.go\n├── Makefile\n├── testdata\n│   ├── sample1.md\n│   └── sample2.md\n└── tree.go\n\n3 directories, 5 files\n```\n\n#### *dry run*\nDoes not create a file and directory.\n\n```console\n$ gtree template | gtree mkdir --dry-run -e .go -e .md -e Makefile\ngtree\n├── cmd\n│   └── gtree\n│       └── main.go\n├── testdata\n│   ├── sample1.md\n│   └── sample2.md\n├── Makefile\n└── tree.go\n\n4 directories, 5 files\n```\n\n![](assets/cli_mkdir_dryrun.png)\n\n\nAny invalid file or directory name will result in an error.\n\n```console\n$ gtree mkdir --dry-run \u003c\u003cEOS\n- root\n  - aa\n  - bb\n    - b/b\nEOS\ninvalid node name: b/b\n```\n\n```console\n$ gtree mkdir --dry-run \u003c\u003cEOS\n- /root\n  - aa\n  - bb\n    - bb\nEOS\ninvalid node name: /root\n```\n\n### *Verify* subcommand\n```console\n$ gtree verify --help\nNAME:\n   gtree verify - Verifies tree structure represented in markdown by comparing it with existing directories.\n                  Let's try 'gtree template | gtree verify'.\n\nUSAGE:\n   gtree verify [command options] [arguments...]\n\nOPTIONS:\n   --file value, -f value  specify the path to markdown file. (default: stdin)\n   --target-dir value      set this option if you want to specify the directory you want to verify. (default: current directory)\n   --strict                set this option if you want strict directory match validation. (default: non strict)\n   --help, -h              show help\n```\n\n#### Try it!\n\n```console\n$ tree example\nexample\n├── README.md\n├── find_pipe_programmable-gtree\n│   ├── README.md\n│   ├── go.mod\n│   ├── go.sum\n│   └── main.go\n├── go-list_pipe_programmable-gtree\n│   ├── README.md\n│   ├── go.mod\n│   ├── go.sum\n│   └── main.go\n├── like_cli\n│   ├── adapter\n│   │   ├── executor.go\n│   │   └── indentation.go\n│   └── main.go\n├── noexist\n│   └── xxx\n└── programmable\n    └── main.go\n\n6 directories, 14 files\n$ cat testdata/sample9.md\n- example\n        - README.md\n        - find_pipe_programmable-gtree\n                - README.md\n                - go.mod\n                - go.sum\n                - main.go\n        - go-list_pipe_programmable-gtree\n                - README.md\n                - go.mod\n                - go.sum\n                - main.go\n        - like_cli\n                - adapter\n                        - executor.go\n                        - indentation.go\n                - main.go\n                - kkk\n        - programmable\n                - main.go\n$ cat testdata/sample9.md | gtree verify --strict\nExtra paths exist:\n        example/noexist\n        example/noexist/xxx\nRequired paths does not exist:\n        example/like_cli/kkk\n```\n\ninspired by [mactat/framed](https://github.com/mactat/framed) !\n\n# Process\n\n\u003e [!NOTE]\n\u003e This process is for the Massive Roots mode.\n\n## e.g. [*gtree/pipeline_tree.go*](https://github.com/ddddddO/gtree/blob/master/pipeline_tree.go)\n\n\u003cimage src=\"assets/process.svg\" width=100%\u003e\n\n\n# Performance\n\n\u003cdetails\u003e\u003csummary\u003esee\u003c/summary\u003e\n\n```console\nddddddo@debian:~/github.com/ddddddO/gtree$ make bench\nrm -rf ./root/ ./root1/ ./root2/ ./root3/ ./root4/ ./root5/ ./root6/ ./root7/ ./root8/ Primate/ gtree/\nrm -rf ./root_a/ ./root_b/ ./root_c/ ./root_d/ ./root_e/ ./root_f/ ./root_g/ ./root_h/ ./root_i/ ./root_j/\ngo test -benchmem -bench Benchmark -benchtime 100x benchmark_simple_test.go\ngoos: linux\ngoarch: amd64\ncpu: 13th Gen Intel(R) Core(TM) i7-1370P\nBenchmarkOutput_simple_singleRoot-20                 100             10149 ns/op            9987 B/op        231 allocs/op\nBenchmarkOutput_simple_tenRoots-20                   100             70643 ns/op           59373 B/op       2121 allocs/op\nBenchmarkOutput_simple_fiftyRoots-20                 100            315096 ns/op          281426 B/op      10488 allocs/op\nBenchmarkOutput_simple_hundredRoots-20               100            586092 ns/op          578288 B/op      20942 allocs/op\nBenchmarkOutput_simple_fiveHundredsRoots-20          100           2934791 ns/op         2817802 B/op     104552 allocs/op\nBenchmarkOutput_simple_thousandRoots-20              100           6264854 ns/op         5785893 B/op     209058 allocs/op\nBenchmarkOutput_simple_3000Roots-20                  100          18641680 ns/op        17045688 B/op     627068 allocs/op\nBenchmarkOutput_simple_6000Roots-20                  100          38605597 ns/op        34247794 B/op    1254075 allocs/op\nBenchmarkOutput_simple_10000Roots-20                 100          79987941 ns/op        59397951 B/op    2090080 allocs/op\nBenchmarkOutput_simple_20000Roots-20                 100         153445564 ns/op        118746704 B/op   4180088 allocs/op\nPASS\nok      command-line-arguments  30.503s\ngo test -benchmem -bench Benchmark -benchtime 100x benchmark_pipeline_test.go\ngoos: linux\ngoarch: amd64\ncpu: 13th Gen Intel(R) Core(TM) i7-1370P\nBenchmarkOutput_pipeline_singleRoot-20                       100             67536 ns/op           20754 B/op        356 allocs/op\nBenchmarkOutput_pipeline_tenRoots-20                         100            235060 ns/op          115166 B/op       2715 allocs/op\nBenchmarkOutput_pipeline_fiftyRoots-20                       100            800429 ns/op          544849 B/op      13215 allocs/op\nBenchmarkOutput_pipeline_hundredRoots-20                     100           1566669 ns/op         1098099 B/op      26321 allocs/op\nBenchmarkOutput_pipeline_fiveHundredsRoots-20                100           9370155 ns/op         5395556 B/op     131178 allocs/op\nBenchmarkOutput_pipeline_thousandRoots-20                    100          19935090 ns/op        10937746 B/op     262249 allocs/op\nBenchmarkOutput_pipeline_3000Roots-20                        100          61218588 ns/op        32470598 B/op     786461 allocs/op\nBenchmarkOutput_pipeline_6000Roots-20                        100         140668786 ns/op        65080805 B/op    1572765 allocs/op\nBenchmarkOutput_pipeline_10000Roots-20                       100         251359838 ns/op        110717084 B/op   2621057 allocs/op\nBenchmarkOutput_pipeline_20000Roots-20                       100         517510413 ns/op        221188080 B/op   5241583 allocs/op\nPASS\nok      command-line-arguments  101.444s\ngo test -benchmem -bench Benchmark -benchtime 100x benchmark_iterator_test.go\ngoos: linux\ngoarch: amd64\ncpu: 13th Gen Intel(R) Core(TM) i7-1370P\nBenchmarkOutput_iterator_singleRoot-20                       100             23219 ns/op           10966 B/op        265 allocs/op\nBenchmarkOutput_iterator_tenRoots-20                         100             95018 ns/op           60049 B/op       2151 allocs/op\nBenchmarkOutput_iterator_fiftyRoots-20                       100            415429 ns/op          281107 B/op      10516 allocs/op\nBenchmarkOutput_iterator_hundredRoots-20                     100            801343 ns/op          576557 B/op      20969 allocs/op\nBenchmarkOutput_iterator_fiveHundredsRoots-20                100           4025727 ns/op         2807096 B/op     104577 allocs/op\nBenchmarkOutput_iterator_thousandRoots-20                    100           8343427 ns/op         5765146 B/op     209084 allocs/op\nBenchmarkOutput_iterator_3000Roots-20                        100          20800851 ns/op        16965023 B/op     627100 allocs/op\nBenchmarkOutput_iterator_6000Roots-20                        100          46313662 ns/op        34079177 B/op    1254118 allocs/op\nBenchmarkOutput_iterator_10000Roots-20                       100          74729899 ns/op        59063939 B/op    2090141 allocs/op\nBenchmarkOutput_iterator_20000Roots-20                       100         151050139 ns/op        117922359 B/op   4180162 allocs/op\nPASS\nok      command-line-arguments  31.057s\nddddddo@debian:~/github.com/ddddddO/gtree$\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eold data\u003c/summary\u003e\n\n\u003e [!WARNING]\n\u003e The following benchmarks are for simple implementation before iterator implementation. The simple implementation is now an iterator implementation, and the performance of the simple implementation is better.\n\u003e Depends on the environment.\n\n- Comparison simple implementation and pipeline implementation.\n- In the case of few Roots, simple implementation is faster in execution!\n\t- Use this one by default.\n- However, for multiple Roots, pipeline implementation execution speed tends to be faster💪✨\n\t- In the CLI, it is available by specifying `--massive`.\n\t- In the Go program, it is available by specifying `WithMassive` func.\n\n\u003cimage src=\"assets/performance.svg\" width=100%\u003e\n\n\u003cdetails\u003e\u003csummary\u003eBenchmark log\u003c/summary\u003e\n\n## Simple implementation\n```console\n11:19:22 \u003e go test -benchmem -bench Benchmark -benchtime 100x benchmark_simple_test.go\ngoos: linux\ngoarch: amd64\ncpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz\nBenchmarkOutput_singleRoot-4                 100             35375 ns/op           13856 B/op        171 allocs/op\nBenchmarkOutput_tenRoots-4                   100            200540 ns/op           72920 B/op       1597 allocs/op\nBenchmarkOutput_fiftyRoots-4                 100            730156 ns/op          569851 B/op       7919 allocs/op\nBenchmarkOutput_hundredRoots-4               100           1706493 ns/op         1714260 B/op      15820 allocs/op\nBenchmarkOutput_fiveHundredsRoots-4          100          16412090 ns/op        32245140 B/op      79022 allocs/op\nBenchmarkOutput_thousandRoots-4              100          55142492 ns/op        120929674 B/op    158025 allocs/op\nBenchmarkOutput_3000Roots-4                  100         489121246 ns/op        1035617527 B/op   474029 allocs/op\nBenchmarkOutput_6000Roots-4                  100        1613641261 ns/op        4087694372 B/op   948033 allocs/op\nBenchmarkOutput_10000Roots-4                 100        3913090646 ns/op        11293191221 B/op         1580035 allocs/op\nPASS\nok      command-line-arguments  614.944s\n```\n\n## Pipeline implementation\n```console\n11:29:43 \u003e go test -benchmem -bench Benchmark -benchtime 100x benchmark_pipeline_test.go\ngoos: linux\ngoarch: amd64\ncpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz\nBenchmarkOutput_pipeline_singleRoot-4                100            188706 ns/op           24236 B/op        300 allocs/op\nBenchmarkOutput_pipeline_tenRoots-4                  100            367758 ns/op          115970 B/op       2186 allocs/op\nBenchmarkOutput_pipeline_fiftyRoots-4                100            947879 ns/op          542188 B/op      10592 allocs/op\nBenchmarkOutput_pipeline_hundredRoots-4              100           1711537 ns/op         1099636 B/op      21094 allocs/op\nBenchmarkOutput_pipeline_fiveHundredsRoots-4         100           6892261 ns/op         5524905 B/op     105107 allocs/op\nBenchmarkOutput_pipeline_thousandRoots-4             100          13100335 ns/op        11225942 B/op     210115 allocs/op\nBenchmarkOutput_pipeline_3000Roots-4                 100          40694497 ns/op        33399766 B/op     630142 allocs/op\nBenchmarkOutput_pipeline_6000Roots-4                 100          85807944 ns/op        66974524 B/op    1260171 allocs/op\nBenchmarkOutput_pipeline_10000Roots-4                100         151486713 ns/op        113908462 B/op   2100208 allocs/op\nPASS\nok      command-line-arguments  30.670s\n```\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n# Documents\n- [GoDoc](https://pkg.go.dev/github.com/ddddddO/gtree)\n\n## English\n- [Want to output a tree in Go?](https://medium.com/@allowing_whip_guineapig_430/want-to-output-a-tree-in-go-1851f9fc9900)\n- [Generate directory trees🌳 and the directories itself📁 using Markdown or Programmatically.](https://www.reddit.com/r/commandline/comments/146nk54/generate_directory_trees_and_the_directories/)\n\n## Japanese\n- [Goでtreeを表現する](https://zenn.dev/ddddddo/articles/8cd85c68763f2e)\n- [Markdown形式の入力からtreeを出力するCLI/Web](https://zenn.dev/ddddddo/articles/ad97623a004496)\n- [Markdown形式の入力からファイル/ディレクトリを生成するCLI/Goパッケージ](https://zenn.dev/ddddddo/articles/460d12e8c07763)\n- [盆栽 (節目の記事)](https://zenn.dev/openlogi/articles/f6cc91ac413c8f)\n- [感想](https://scrapbox.io/ddddddo/useful_tools)\n\n# Contributing\nIf you have any bugs or requests, please create an [issue](https://github.com/ddddddO/gtree/issues)! Pull Requests are also accepted.\nI will make a best effort to check them😅\n\n## Contributors\n\n\u003ca href=\"https://github.com/ddddddO/gtree/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=ddddddO/gtree\" /\u003e\n\u003c/a\u003e\n\nthanks!  \n\n# Test coverage\n![treemap](/assets/test_treemap.svg)\n\n...generated by [nikolaydubina/go-cover-treemap](https://github.com/nikolaydubina/go-cover-treemap) !\n\n# Stargazers over time\n[![Stargazers over time](https://starchart.cc/ddddddO/gtree.svg?variant=adaptive)](https://starchart.cc/ddddddO/gtree)\n\n[^1]: Gopher retrieved from [egonelbre/gophers](https://github.com/egonelbre/gophers) !","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddddddo%2Fgtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddddddo%2Fgtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddddddo%2Fgtree/lists"}