All Projects โ†’ ddddddO โ†’ gtree

ddddddO / gtree

Licence: BSD-2-Clause license
Output tree๐ŸŒณ or Make directories๐Ÿ“ from #Markdown or Programmatically. Provide CLI, Golang library and Web (using #Wasm ).

Programming Languages

go
31211 projects - #10 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects
Makefile
30231 projects
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to gtree

fsify
Convert an array of objects into a persistent or temporary directory structure.
Stars: โœญ 24 (-72.73%)
Mutual labels:  tree, filesystem, directory, file
directory-structure
๐Ÿ“ฆ Print a directory tree structure in your Python code.
Stars: โœญ 40 (-54.55%)
Mutual labels:  tree, directory, file
Tree Node Cli
๐ŸŒฒ Node.js library to list the contents of directories in a tree-like format, similar to the Linux tree command
Stars: โœญ 102 (+15.91%)
Mutual labels:  tree, directory, file
files
Useful methods to manage files and directories
Stars: โœญ 27 (-69.32%)
Mutual labels:  filesystem, directory, file
Renamer
Rename files in bulk.
Stars: โœญ 240 (+172.73%)
Mutual labels:  filesystem, file
Copy Webpack Plugin
Copy files and directories with webpack
Stars: โœญ 2,679 (+2944.32%)
Mutual labels:  filesystem, file
Pwastats
A directory of Progressive Web App case studies.
Stars: โœญ 88 (+0%)
Mutual labels:  service-worker, directory
Flametree
๐Ÿ”ฅ Python file and zip operations made easy
Stars: โœญ 148 (+68.18%)
Mutual labels:  filesystem, file
Nohost
A web server in your web browser
Stars: โœญ 164 (+86.36%)
Mutual labels:  service-worker, filesystem
gitree
Print a directory tree that shows Git status and ignores files dictated by .gitignore.
Stars: โœญ 32 (-63.64%)
Mutual labels:  tree, directory
Repository Tree
๐ŸŒฒPretty display directory tree view of a GitHub repository.
Stars: โœญ 56 (-36.36%)
Mutual labels:  tree, directory
Datafiles
A file-based ORM for Python dataclasses.
Stars: โœญ 113 (+28.41%)
Mutual labels:  toml, filesystem
Aiofile
Real asynchronous file operations with asyncio support.
Stars: โœญ 214 (+143.18%)
Mutual labels:  filesystem, file
Filehound
Flexible and fluent interface for searching the file system
Stars: โœญ 190 (+115.91%)
Mutual labels:  filesystem, file
gologger
A concurrent, fast queue/service worker based filesystem logging system perfect for servers with concurrent connections
Stars: โœญ 16 (-81.82%)
Mutual labels:  service-worker, file
Filesystem
FileSystem is an application that allows you to browse the content of your iPhone disk, displaying file and folders, files contents, and detailed informations about file and folder permissions.
Stars: โœญ 148 (+68.18%)
Mutual labels:  filesystem, file
FileRenamerDiff
A File Renamer App featuring a difference display before and after the change.
Stars: โœญ 32 (-63.64%)
Mutual labels:  filesystem, file
Hypertag
Knowledge Management for Humans using Machine Learning & Tags
Stars: โœญ 116 (+31.82%)
Mutual labels:  filesystem, file
File Storage
File storage abstraction for Yii2
Stars: โœญ 116 (+31.82%)
Mutual labels:  filesystem, file
Coc Explorer
๐Ÿ“ Explorer for coc.nvim
Stars: โœญ 722 (+720.45%)
Mutual labels:  tree, file

gtree

GitHub Pages
GitHub release Go Reference
License Mentioned in Awesome Go
codecov Go Report Card ci

Output tree๐ŸŒณ or Make directories๐Ÿ“ from Markdown or Programmatically. Provide CLI, Go library and Web.

# Description
โ”œโ”€โ”€ Output tree from markdown or programmatically.
โ”‚   โ”œโ”€โ”€ Output format is tree or yaml or toml or json.
โ”‚   โ””โ”€โ”€ Default tree.
โ”œโ”€โ”€ Make directories from markdown or programmatically.
โ”‚   โ”œโ”€โ”€ It is possible to dry run.
โ”‚   โ””โ”€โ”€ You can use `-e` flag to make specified extensions as file.
โ”œโ”€โ”€ Output a markdown template that can be used with either `output` subcommand or `mkdir` subcommand.
โ””โ”€โ”€ Provide CLI, Go library and Web.
This description is output by
$ cat testdata/sample0.md | gtree output --fs

Process

e.g. gtree/tree_handler.go

Performance

Warning
Depends on the environment.

  • Comparison before and after software architecture was changed.
  • In the case of few Roots, previous architecture is faster in execution๐Ÿ˜…
  • However, for multiple Roots, execution speed tends to be faster๐Ÿ’ชโœจ

benchmark

Before pipelining

$ go test -benchmem -bench Benchmark -benchtime 100x tree_handler_benchmark_test.go
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
BenchmarkOutput_singleRoot-4                 100             24948 ns/op           14400 B/op        185 allocs/op
BenchmarkOutput_tenRoots-4                   100            283504 ns/op           65320 B/op       1710 allocs/op
BenchmarkOutput_fiftyRoots-4                 100            995910 ns/op          305658 B/op       8474 allocs/op
BenchmarkOutput_hundredRoots-4               100           1649849 ns/op          631196 B/op      16927 allocs/op
BenchmarkOutput_fiveHundredsRoots-4          100           7069195 ns/op         3198760 B/op      84534 allocs/op
BenchmarkOutput_thousandRoots-4              100          15263601 ns/op         6587536 B/op     169039 allocs/op
BenchmarkOutput_3000Roots-4                  100          47383020 ns/op        19505832 B/op     507046 allocs/op
BenchmarkOutput_6000Roots-4                  100          96684490 ns/op        39203833 B/op    1014051 allocs/op
BenchmarkOutput_10000Roots-4                 100         164449890 ns/op        67676933 B/op    1690056 allocs/op
BenchmarkOutput_20000Roots-4                 100         339919674 ns/op        135144612 B/op   3380061 allocs/op
PASS
ok      command-line-arguments  68.124s

After pipelining

$ go test -benchmem -bench Benchmark -benchtime 100x tree_handler_benchmark_test.go
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
BenchmarkOutput_singleRoot-4                 100            130346 ns/op           24021 B/op        304 allocs/op
BenchmarkOutput_tenRoots-4                   100            324765 ns/op          120458 B/op       2301 allocs/op
BenchmarkOutput_fiftyRoots-4                 100            822572 ns/op          565455 B/op      11182 allocs/op
BenchmarkOutput_hundredRoots-4               100           1489798 ns/op         1147089 B/op      22288 allocs/op
BenchmarkOutput_fiveHundredsRoots-4          100           6546967 ns/op         5763994 B/op     111099 allocs/op
BenchmarkOutput_thousandRoots-4              100          13072156 ns/op        11705324 B/op     222112 allocs/op
BenchmarkOutput_3000Roots-4                  100          37430405 ns/op        34838155 B/op     666142 allocs/op
BenchmarkOutput_6000Roots-4                  100          75890968 ns/op        69852265 B/op    1332183 allocs/op
BenchmarkOutput_10000Roots-4                 100         125694694 ns/op        118704856 B/op   2220232 allocs/op
BenchmarkOutput_20000Roots-4                 100         242875644 ns/op        237242818 B/op   4440315 allocs/op
PASS
ok      command-line-arguments  50.962s

Web

https://ddddddo.github.io/gtree/

This page is that converts from Markdown to tree!
This page calls a function that outputs tree. This function is a Go package compiled as WebAssembly.
The symbols that can be used in Markdown are *, -, +, and #.
You can change the branches like in the image below.
Also, once loaded, you can enjoy offline!

source code

Package(1) / like CLI

๐Ÿ‘‰ read me!

Package(2) / generate a tree programmatically

๐Ÿ‘‰ read me!

CLI

Installation

Go (requires 1.18 or later)

$ go install github.com/ddddddO/gtree/cmd/gtree@latest

Homebrew

$ brew install ddddddO/tap/gtree

Scoop

$ scoop bucket add ddddddO https://github.com/ddddddO/scoop-bucket.git
$ scoop install ddddddO/gtree

docker image

$ docker pull ghcr.io/ddddddo/gtree:latest
$ docker run ghcr.io/ddddddo/gtree:latest template | docker run -i ghcr.io/ddddddo/gtree:latest output
gtree
โ”œโ”€โ”€ cmd
โ”‚   โ””โ”€โ”€ gtree
โ”‚       โ””โ”€โ”€ main.go
โ”œโ”€โ”€ testdata
โ”‚   โ”œโ”€โ”€ sample1.md
โ”‚   โ””โ”€โ”€ sample2.md
โ”œโ”€โ”€ Makefile
โ””โ”€โ”€ tree.go

etc

download binary from here.

Usage

$ gtree --help
NAME:
   gtree - This CLI outputs tree or makes directories from markdown.

USAGE:
   gtree [global options] command [command options] [arguments...]

COMMANDS:
   output, o, out     Output tree from markdown. Let's try 'gtree template | gtree output'. Output format is tree or yaml or toml or json. Default tree.
   mkdir, m           Make directories(and files) from markdown. It is possible to dry run. Let's try 'gtree template | gtree mkdir -e .go -e .md -e Makefile'.
   template, t, tmpl  Output markdown template.
   version, v         Output gtree version.
   help, h            Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)
  • The symbols that can be used in Markdown are *, -, +, and #.

Output subcommand

$ gtree output --help
NAME:
   gtree output - Output tree from markdown. Let's try 'gtree template | gtree output'. Output format is tree or yaml or toml or json. Default tree.

USAGE:
   gtree output [command options] [arguments...]

OPTIONS:
   --file value, -f value  Markdown file path. (default: stdin)
   --two-spaces, --ts      Markdown is Two Spaces indentation. (default: tab spaces)
   --four-spaces, --fs     Markdown is Four Spaces indentation. (default: tab spaces)
   --json, -j              Output JSON format. (default: stdout)
   --yaml, -y              Output YAML format. (default: stdout)
   --toml, -t              Output TOML format. (default: stdout)
   --watch, -w             Watching markdown file. (default: false)
   --help, -h              show help (default: false)
$ gtree template
- gtree
        - cmd
                - gtree
                        - main.go
        - testdata
                - sample1.md
                - sample2.md
        - Makefile
        - tree.go
$ gtree template | gtree output
gtree
โ”œโ”€โ”€ cmd
โ”‚   โ””โ”€โ”€ gtree
โ”‚       โ””โ”€โ”€ main.go
โ”œโ”€โ”€ testdata
โ”‚   โ”œโ”€โ”€ sample1.md
โ”‚   โ””โ”€โ”€ sample2.md
โ”œโ”€โ”€ Makefile
โ””โ”€โ”€ tree.go

When Markdown is indented as a tab.

โ”œโ”€โ”€ gtree output -f testdata/sample1.md
โ”œโ”€โ”€ cat testdata/sample1.md | gtree output -f -
โ””โ”€โ”€ cat testdata/sample1.md | gtree output

For 2 or 4 spaces instead of tabs, -ts or -fs is required.

More details
  • Usage other than representing a directory.
$ cat testdata/sample2.md | gtree output
k8s_resources
โ”œโ”€โ”€ (Tier3)
โ”‚   โ””โ”€โ”€ (Tier2)
โ”‚       โ””โ”€โ”€ (Tier1)
โ”‚           โ””โ”€โ”€ (Tier0)
โ”œโ”€โ”€ Deployment
โ”‚   โ””โ”€โ”€ ReplicaSet
โ”‚       โ””โ”€โ”€ Pod
โ”‚           โ””โ”€โ”€ container(s)
โ”œโ”€โ”€ CronJob
โ”‚   โ””โ”€โ”€ Job
โ”‚       โ””โ”€โ”€ Pod
โ”‚           โ””โ”€โ”€ container(s)
โ”œโ”€โ”€ (empty)
โ”‚   โ””โ”€โ”€ DaemonSet
โ”‚       โ””โ”€โ”€ Pod
โ”‚           โ””โ”€โ”€ container(s)
โ””โ”€โ”€ (empty)
    โ””โ”€โ”€ StatefulSet
        โ””โ”€โ”€ Pod
            โ””โ”€โ”€ container(s)

  • Two spaces indent
$ cat testdata/sample4.md | gtree output -ts
a
โ”œโ”€โ”€ i
โ”‚   โ”œโ”€โ”€ u
โ”‚   โ”‚   โ”œโ”€โ”€ k
โ”‚   โ”‚   โ””โ”€โ”€ kk
โ”‚   โ””โ”€โ”€ t
โ”œโ”€โ”€ e
โ”‚   โ””โ”€โ”€ o
โ””โ”€โ”€ g
  • Four spaces indent
$ cat testdata/sample5.md | gtree output -fs
a
โ”œโ”€โ”€ i
โ”‚   โ”œโ”€โ”€ u
โ”‚   โ”‚   โ”œโ”€โ”€ k
โ”‚   โ”‚   โ””โ”€โ”€ kk
โ”‚   โ””โ”€โ”€ t
โ”œโ”€โ”€ e
โ”‚   โ””โ”€โ”€ o
โ””โ”€โ”€ g
  • Multiple roots
$ cat testdata/sample6.md | gtree output
a
โ”œโ”€โ”€ i
โ”‚   โ”œโ”€โ”€ u
โ”‚   โ”‚   โ”œโ”€โ”€ k
โ”‚   โ”‚   โ””โ”€โ”€ kk
โ”‚   โ””โ”€โ”€ t
โ”œโ”€โ”€ e
โ”‚   โ””โ”€โ”€ o
โ””โ”€โ”€ g
a
โ”œโ”€โ”€ i
โ”‚   โ”œโ”€โ”€ u
โ”‚   โ”‚   โ”œโ”€โ”€ k
โ”‚   โ”‚   โ””โ”€โ”€ kk
โ”‚   โ””โ”€โ”€ t
โ”œโ”€โ”€ e
โ”‚   โ””โ”€โ”€ o
โ””โ”€โ”€ g
  • Output JSON
$ cat testdata/sample5.md | gtree output -fs -j | jq
{
  "value": "a",
  "children": [
    {
      "value": "i",
      "children": [
        {
          "value": "u",
          "children": [
            {
              "value": "k",
              "children": null
            },
            {
              "value": "kk",
              "children": null
            }
          ]
        },
        {
          "value": "t",
          "children": null
        }
      ]
    },
    {
      "value": "e",
      "children": [
        {
          "value": "o",
          "children": null
        }
      ]
    },
    {
      "value": "g",
      "children": null
    }
  ]
}
  • Output YAML
$ cat testdata/sample5.md | gtree output -fs -y
value: a
children:
- value: i
  children:
  - value: u
    children:
    - value: k
      children: []
    - value: kk
      children: []
  - value: t
    children: []
- value: e
  children:
  - value: o
    children: []
- value: g
  children: []
  • Output TOML
$ cat testdata/sample5.md | gtree output -fs -t
value = 'a'
[[children]]
value = 'i'
[[children.children]]
value = 'u'
[[children.children.children]]
value = 'k'
children = []
[[children.children.children]]
value = 'kk'
children = []

[[children.children]]
value = 't'
children = []

[[children]]
value = 'e'
[[children.children]]
value = 'o'
children = []

[[children]]
value = 'g'
children = []

Mkdir subcommand

$ gtree mkdir --help
NAME:
   gtree mkdir - Make directories from markdown. It is possible to dry run. Let's try 'gtree template | gtree mkdir -e .go -e .md -e Makefile'.

USAGE:
   gtree mkdir [command options] [arguments...]

OPTIONS:
   --file value, -f value                    Markdown file path. (default: stdin)
   --two-spaces, --ts                        Markdown is Two Spaces indentation. (default: tab spaces)
   --four-spaces, --fs                       Markdown is Four Spaces indentation. (default: tab spaces)
   --dry-run, -d, --dr                       Dry run. Detects node that is invalid for directory generation. The order of the output and made directories does not always match. (default: false)
   --extension value, -e value, --ext value  Specified extension will be created as file.
   --help, -h                                show help (default: false)
$ gtree template
- gtree
        - cmd
                - gtree
                        - main.go
        - testdata
                - sample1.md
                - sample2.md
        - Makefile
        - tree.go
$ gtree template | gtree mkdir
$ tree gtree/
gtree/
โ”œโ”€โ”€ cmd
โ”‚   โ””โ”€โ”€ gtree
โ”‚       โ””โ”€โ”€ main.go
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ testdata
โ”‚   โ”œโ”€โ”€ sample1.md
โ”‚   โ””โ”€โ”€ sample2.md
โ””โ”€โ”€ tree.go

8 directories, 0 files
make directories and files
$ gtree template
- gtree
        - cmd
                - gtree
                        - main.go
        - testdata
                - sample1.md
                - sample2.md
        - Makefile
        - tree.go
$ gtree template | gtree mkdir -e .go -e .md -e Makefile
$ tree gtree/
gtree/
โ”œโ”€โ”€ cmd
โ”‚   โ””โ”€โ”€ gtree
โ”‚       โ””โ”€โ”€ main.go
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ testdata
โ”‚   โ”œโ”€โ”€ sample1.md
โ”‚   โ””โ”€โ”€ sample2.md
โ””โ”€โ”€ tree.go

3 directories, 5 files
dry run

Does not create a file and directory.

$ gtree template | gtree mkdir --dry-run -e .go -e .md -e Makefile
gtree
โ”œโ”€โ”€ cmd
โ”‚   โ””โ”€โ”€ gtree
โ”‚       โ””โ”€โ”€ main.go
โ”œโ”€โ”€ testdata
โ”‚   โ”œโ”€โ”€ sample1.md
โ”‚   โ””โ”€โ”€ sample2.md
โ”œโ”€โ”€ Makefile
โ””โ”€โ”€ tree.go

4 directories, 5 files

Any invalid file or directory name will result in an error.

$ gtree mkdir --dry-run --ts <<EOS
- root
  - aa
  - bb
    - b/b
EOS
invalid node name: b/b
$ gtree mkdir --dry-run --ts <<EOS
- /root
  - aa
  - bb
    - bb
EOS
invalid path: /root/aa

Documents

Star History

Star History Chart

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].