GithubHelp home page GithubHelp logo

ddddddo / gtree Goto Github PK

View Code? Open in Web Editor NEW
193.0 5.0 7.0 20.24 MB

Using either Markdown or Programmatically to generate trees๐ŸŒณ and directories๐Ÿ“, and to verify directories๐Ÿ”. Provide CLI, Golang library and Web.

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

License: BSD 2-Clause "Simplified" License

Go 85.70% Makefile 0.78% Dockerfile 0.12% HTML 1.55% JavaScript 6.08% CSS 5.71% Shell 0.07%
tree markdown tree-structure directory wasm cli golang trees

gtree's Introduction

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


Using either Markdown or Programmatically to generate directory trees๐ŸŒณ and directories๐Ÿ—‚, and to verify directories๐Ÿ”. Provide CLI, Golang library and Web.

Table of Contents

Acknowledgments

Thanks for providing very useful CLI for cloud storage tree output๐Ÿคฉ๐ŸŽ‰
Everyone is encouraged to use them!

CLI for Amazon S3 tree output.
aws s3 command does not do what tree command does, but stree command can display tree!

CLI for Google Cloud Storage tree output.
gcloud storage command does not do what tree command does, but gcstree command can display tree!

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 #.
Indentation represents hierarchy. The indentation can be whatever you specify, but use the same pattern.
You can change the branches like in the image below.
Also, once loaded, you can enjoy offline!

You can open it in your browser with

$ gtree web

source code

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

deb
$ export GTREE_VERSION=X.X.X
$ curl -o gtree.deb -L https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.deb
$ dpkg -i gtree.deb

rpm
$ export GTREE_VERSION=X.X.X
$ yum install https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.rpm

apk
$ export GTREE_VERSION=X.X.X
$ curl -o gtree.apk -L https://github.com/ddddddO/gtree/releases/download/v$GTREE_VERSION/gtree_$GTREE_VERSION-1_amd64.apk
$ apk add --allow-untrusted gtree.apk

AUR
$ wip...

Nix
$ nix-env -i gtree
or
$ nix-shell -p gtree

MacPorts
$ port install gtree

aqua
$ aqua g -i ddddddO/gtree

Docker
$ 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 uses Markdown to generate directory trees and directories itself, and also verifies directories.
           The symbols that can be used in Markdown are '-', '+', '*', and '#'.
           Within Markdown, indentation represents hierarchy. The indentation can be whatever you specify, but use the same pattern.

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

VERSION:
   1.10.2 / revision 85520a1

COMMANDS:
   output, o, out     Outputs tree from markdown.
                      Let's try 'gtree template | gtree output'.
   mkdir, m           Makes directories and files from markdown. It is possible to dry run.
                      Let's try 'gtree template | gtree mkdir -e .go -e .md -e Makefile'.
   verify, vf         Verifies tree structure represented in markdown by comparing it with existing directories.
                      Let's try 'gtree template | gtree verify'.
   template, t, tmpl  Outputs markdown template. Use it to try out gtree CLI.
   web, w, www        Opens "Tree Maker" in your browser and shows the URL in terminal.
   version, v         Prints the version.
   help, h            Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Output subcommand

$ gtree output --help
NAME:
   gtree output - Outputs tree from markdown.
                  Let's try 'gtree template | gtree output'.

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

OPTIONS:
   --file value, -f value               specify the path to markdown file. (default: stdin)
   --massive, -m                        set this option when there are very many blocks of markdown. (default: false)
   --massive-timeout value, --mt value  set this option if you want to set a timeout. (default: 0s)
   --format value                       set this option when specifying output format. "json", "yaml", "toml"
   --watch, -w                          follow changes in markdown file. (default: false)
   --help, -h                           show help

Try it!

$ 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

Other pattern.

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

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)
    โ””โ”€โ”€ StatefulSet
        โ””โ”€โ”€ Pod
            โ””โ”€โ”€ container(s)

Multiple roots

$ cat testdata/sample6.md | gtree output
Artiodactyla
โ”œโ”€โ”€ Artiofabula
โ”‚   โ”œโ”€โ”€ Cetruminantia
โ”‚   โ”‚   โ”œโ”€โ”€ Whippomorpha
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Hippopotamidae
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Cetacea
โ”‚   โ”‚   โ””โ”€โ”€ Ruminantia
โ”‚   โ””โ”€โ”€ Suina
โ””โ”€โ”€ Tylopoda
Carnivora
โ”œโ”€โ”€ Feliformia
โ””โ”€โ”€ Caniformia
    โ”œโ”€โ”€ Canidae
    โ””โ”€โ”€ Arctoidea
        โ”œโ”€โ”€ Ursidae
        โ””โ”€โ”€ x
            โ”œโ”€โ”€ Pinnipedia
            โ””โ”€โ”€ Musteloidea
                โ”œโ”€โ”€ Ailuridae
                โ””โ”€โ”€ x
                    โ”œโ”€โ”€ Mephitidae
                    โ””โ”€โ”€ x
                        โ”œโ”€โ”€ Procyonidae
                        โ””โ”€โ”€ Mustelidae

Output JSON

$ cat testdata/sample5.md | gtree output --format json | 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 --format yaml
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 --format toml
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 - Makes directories and files 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                                       specify the path to markdown file. (default: stdin)
   --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)
   --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"
   --target-dir value                                           set this option if you want to specify the directory you want to make directory. (default: current directory)
   --help, -h                                                   show help

Try it!

$ 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 <<EOS
- root
  - aa
  - bb
    - b/b
EOS
invalid node name: b/b
$ gtree mkdir --dry-run <<EOS
- /root
  - aa
  - bb
    - bb
EOS
invalid node name: /root

Verify subcommand

$ gtree verify --help
NAME:
   gtree verify - Verifies tree structure represented in markdown by comparing it with existing directories.
                  Let's try 'gtree template | gtree verify'.

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

OPTIONS:
   --file value, -f value  specify the path to markdown file. (default: stdin)
   --target-dir value      set this option if you want to specify the directory you want to verify. (default: current directory)
   --strict                set this option if you want strict directory match validation. (default: non strict)
   --help, -h              show help

Try it!

$ tree example
example
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ find_pipe_programmable-gtree
โ”‚ย ย  โ”œโ”€โ”€ README.md
โ”‚ย ย  โ”œโ”€โ”€ go.mod
โ”‚ย ย  โ”œโ”€โ”€ go.sum
โ”‚ย ย  โ””โ”€โ”€ main.go
โ”œโ”€โ”€ go-list_pipe_programmable-gtree
โ”‚ย ย  โ”œโ”€โ”€ README.md
โ”‚ย ย  โ”œโ”€โ”€ go.mod
โ”‚ย ย  โ”œโ”€โ”€ go.sum
โ”‚ย ย  โ””โ”€โ”€ main.go
โ”œโ”€โ”€ like_cli
โ”‚ย ย  โ”œโ”€โ”€ adapter
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ executor.go
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ indentation.go
โ”‚ย ย  โ””โ”€โ”€ main.go
โ”œโ”€โ”€ noexist
โ”‚ย ย  โ””โ”€โ”€ xxx
โ””โ”€โ”€ programmable
    โ””โ”€โ”€ main.go

6 directories, 14 files
$ cat testdata/sample9.md
- example
        - README.md
        - find_pipe_programmable-gtree
                - README.md
                - go.mod
                - go.sum
                - main.go
        - go-list_pipe_programmable-gtree
                - README.md
                - go.mod
                - go.sum
                - main.go
        - like_cli
                - adapter
                        - executor.go
                        - indentation.go
                - main.go
                - kkk
        - programmable
                - main.go
$ cat testdata/sample9.md | gtree verify --strict
Extra paths exist:
        example/noexist
        example/noexist/xxx
Required paths does not exist:
        example/like_cli/kkk

inspired by mactat/framed !

Library - Markdown to tree structure

Installation

Go version requires 1.18 or later.

$ go get github.com/ddddddO/gtree

Usage

The symbols that can be used in Markdown are *, -, +, and #.

Function Description Available optional functions
Output can output trees WithBranchFormatIntermedialNode
WithBranchFormatLastNode
WithEncodeJSON
WithEncodeTOML
WithEncodeYAML
WithMassive
Mkdir can create directories WithTargetDir
WithFileExtensions
WithDryRun
WithMassive
Verify can output the difference between markdown and directories WithTargetDir
WithStrictVerify
WithMassive
Walk can execute user-defined function while traversing tree structure recursively WithBranchFormatIntermedialNode
WithBranchFormatLastNode
WithMassive

Output func

package main

import (
	"bytes"
	"fmt"
	"os"
	"strings"

	"github.com/ddddddO/gtree"
)

func main() {
	r1 := bytes.NewBufferString(strings.TrimSpace(`
- root
	- dddd
		- kkkkkkk
			- lllll
				- ffff
				- LLL
					- WWWWW
						- ZZZZZ
				- ppppp
					- KKK
						- 1111111
							- AAAAAAA
	- eee`))
	if err := gtree.Output(os.Stdout, r1); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// root
	// โ”œโ”€โ”€ dddd
	// โ”‚   โ””โ”€โ”€ kkkkkkk
	// โ”‚       โ””โ”€โ”€ lllll
	// โ”‚           โ”œโ”€โ”€ ffff
	// โ”‚           โ”œโ”€โ”€ LLL
	// โ”‚           โ”‚   โ””โ”€โ”€ WWWWW
	// โ”‚           โ”‚       โ””โ”€โ”€ ZZZZZ
	// โ”‚           โ””โ”€โ”€ ppppp
	// โ”‚               โ””โ”€โ”€ KKK
	// โ”‚                   โ””โ”€โ”€ 1111111
	// โ”‚                       โ””โ”€โ”€ AAAAAAA
	// โ””โ”€โ”€ eee

	r2 := bytes.NewBufferString(strings.TrimSpace(`
- a
  - i
    - u
      - k
      - kk
    - t
  - e
    - o
  - g`))

	// You can customize branch format.
	if err := gtree.Output(os.Stdout, r2,
		gtree.WithBranchFormatIntermedialNode("+->", ":   "),
		gtree.WithBranchFormatLastNode("+->", "    "),
	); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// a
	// +-> i
	// :   +-> u
	// :   :   +-> k
	// :   :   +-> kk
	// :   +-> t
	// +-> e
	// :   +-> o
	// +-> g
}

You can also output JSON/YAML/TOML.

  • gtree.WithEncodeJSON()
  • gtree.WithEncodeTOML()
  • gtree.WithEncodeYAML()

Mkdir func

gtree.Mkdir func makes directories.

You can use gtree.WithFileExtensions func to make specified extensions as file.

Verify func

gtree.Verify func verifies directories.

You can use gtree.WithTargetDir func / gtree.WithStrictVerify func.

Walk func

See sample program
package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/ddddddO/gtree"
)

func main() {
	src := strings.TrimSpace(`
- a
  - i
    - u
      - k
  - kk
    - t
- e
  - o
    - g`)

	callback := func(wn *gtree.WalkerNode) error {
		fmt.Println(wn.Row())
		return nil
	}

	if err := gtree.Walk(strings.NewReader(src), callback); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// a
	// โ”œโ”€โ”€ i
	// โ”‚   โ””โ”€โ”€ u
	// โ”‚       โ””โ”€โ”€ k
	// โ””โ”€โ”€ kk
	//     โ””โ”€โ”€ t
	// e
	// โ””โ”€โ”€ o
	//     โ””โ”€โ”€ g

	callback2 := func(wn *gtree.WalkerNode) error {
		fmt.Println("WalkerNode's methods called...")
		fmt.Printf("\tName     : %s\n", wn.Name())
		fmt.Printf("\tBranch   : %s\n", wn.Branch())
		fmt.Printf("\tRow      : %s\n", wn.Row())
		fmt.Printf("\tLevel    : %d\n", wn.Level())
		fmt.Printf("\tPath     : %s\n", wn.Path())
		fmt.Printf("\tHasChild : %t\n", wn.HasChild())
		return nil
	}

	if err := gtree.Walk(strings.NewReader(src), callback2); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// WalkerNode's methods called...
	// 	Name     : a
	// 	Branch   : 
	// 	Row      : a
	// 	Level    : 1
	// 	Path     : a
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : i
	// 	Branch   : โ”œโ”€โ”€
	// 	Row      : โ”œโ”€โ”€ i
	// 	Level    : 2
	// 	Path     : a/i
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : u
	// 	Branch   : โ”‚   โ””โ”€โ”€
	// 	Row      : โ”‚   โ””โ”€โ”€ u
	// 	Level    : 3
	// 	Path     : a/i/u
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : k
	// 	Branch   : โ”‚       โ””โ”€โ”€
	// 	Row      : โ”‚       โ””โ”€โ”€ k
	// 	Level    : 4
	// 	Path     : a/i/u/k
	// 	HasChild : false
	// WalkerNode's methods called...
	// 	Name     : kk
	// 	Branch   : โ””โ”€โ”€
	// 	Row      : โ””โ”€โ”€ kk
	// 	Level    : 2
	// 	Path     : a/kk
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : t
	// 	Branch   :     โ””โ”€โ”€
	// 	Row      :     โ””โ”€โ”€ t
	// 	Level    : 3
	// 	Path     : a/kk/t
	// 	HasChild : false
	// WalkerNode's methods called...
	// 	Name     : e
	// 	Branch   : 
	// 	Row      : e
	// 	Level    : 1
	// 	Path     : e
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : o
	// 	Branch   : โ””โ”€โ”€
	// 	Row      : โ””โ”€โ”€ o
	// 	Level    : 2
	// 	Path     : e/o
	// 	HasChild : true
	// WalkerNode's methods called...
	// 	Name     : g
	// 	Branch   :     โ””โ”€โ”€
	// 	Row      :     โ””โ”€โ”€ g
	// 	Level    : 3
	// 	Path     : e/o/g
	// 	HasChild : false
}

inspired by xlab/treeprint !

Library - Programmable tree structure

Note

The gonew command can be used to set up sample project using gtree library.
See here for details.

Installation

Go version requires 1.18 or later.

$ go get github.com/ddddddO/gtree

Usage

Function Description Available optional functions
OutputProgrammably can output tree WithBranchFormatIntermedialNode
WithBranchFormatLastNode
WithEncodeJSON
WithEncodeTOML
WithEncodeYAML
MkdirProgrammably can create directories WithTargetDir
WithFileExtensions
WithDryRun
VerifyProgrammably can output the difference between tree you composed and directories WithTargetDir
WithStrictVerify
WalkProgrammably can execute user-defined function while traversing tree structure recursively WithBranchFormatIntermedialNode
WithBranchFormatLastNode

OutputProgrammably func

package main

import (
	"fmt"
	"os"

	"github.com/ddddddO/gtree"
)

func main() {
	var root *gtree.Node = gtree.NewRoot("root")
	root.Add("child 1").Add("child 2").Add("child 3")
	var child4 *gtree.Node = root.Add("child 1").Add("child 2").Add("child 4")
	child4.Add("child 5")
	child4.Add("child 6").Add("child 7")
	root.Add("child 8")
	// you can customize branch format.
	if err := gtree.OutputProgrammably(os.Stdout, root,
		gtree.WithBranchFormatIntermedialNode("+--", ":   "),
		gtree.WithBranchFormatLastNode("+--", "    "),
	); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// root
	// +-- child 1
	// :   +-- child 2
	// :       +-- child 3
	// :       +-- child 4
	// :           +-- child 5
	// :           +-- child 6
	// :               +-- child 7
	// +-- child 8

	primate := preparePrimate()
	// default branch format.
	if err := gtree.OutputProgrammably(os.Stdout, primate); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// Primate
	// โ”œโ”€โ”€ Strepsirrhini
	// โ”‚   โ”œโ”€โ”€ Lemuriformes
	// โ”‚   โ”‚   โ”œโ”€โ”€ Lemuroidea
	// โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Cheirogaleidae
	// โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Indriidae
	// โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Lemuridae
	// โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Lepilemuridae
	// โ”‚   โ”‚   โ””โ”€โ”€ Daubentonioidea
	// โ”‚   โ”‚       โ””โ”€โ”€ Daubentoniidae
	// โ”‚   โ””โ”€โ”€ Lorisiformes
	// โ”‚       โ”œโ”€โ”€ Galagidae
	// โ”‚       โ””โ”€โ”€ Lorisidae
	// โ””โ”€โ”€ Haplorrhini
	//     โ”œโ”€โ”€ Tarsiiformes
	//     โ”‚   โ””โ”€โ”€ Tarsiidae
	//     โ””โ”€โ”€ Simiiformes
	//         โ”œโ”€โ”€ Platyrrhini
	//         โ”‚   โ”œโ”€โ”€ Ceboidea
	//         โ”‚   โ”‚   โ”œโ”€โ”€ Atelidae
	//         โ”‚   โ”‚   โ””โ”€โ”€ Cebidae
	//         โ”‚   โ””โ”€โ”€ Pithecioidea
	//         โ”‚       โ””โ”€โ”€ Pitheciidae
	//         โ””โ”€โ”€ Catarrhini
	//             โ”œโ”€โ”€ Cercopithecoidea
	//             โ”‚   โ””โ”€โ”€ Cercopithecidae
	//             โ””โ”€โ”€ Hominoidea
	//                 โ”œโ”€โ”€ Hylobatidae
	//                 โ””โ”€โ”€ Hominidae
}

func preparePrimate() *gtree.Node {
	primate := gtree.NewRoot("Primate")
	strepsirrhini := primate.Add("Strepsirrhini")
	haplorrhini := primate.Add("Haplorrhini")
	lemuriformes := strepsirrhini.Add("Lemuriformes")
	lorisiformes := strepsirrhini.Add("Lorisiformes")

	lemuroidea := lemuriformes.Add("Lemuroidea")
	lemuroidea.Add("Cheirogaleidae")
	lemuroidea.Add("Indriidae")
	lemuroidea.Add("Lemuridae")
	lemuroidea.Add("Lepilemuridae")

	lemuriformes.Add("Daubentonioidea").Add("Daubentoniidae")

	lorisiformes.Add("Galagidae")
	lorisiformes.Add("Lorisidae")

	haplorrhini.Add("Tarsiiformes").Add("Tarsiidae")
	simiiformes := haplorrhini.Add("Simiiformes")

	platyrrhini := haplorrhini.Add("Platyrrhini")
	ceboidea := platyrrhini.Add("Ceboidea")
	ceboidea.Add("Atelidae")
	ceboidea.Add("Cebidae")
	platyrrhini.Add("Pithecioidea").Add("Pitheciidae")

	catarrhini := simiiformes.Add("Catarrhini")
	catarrhini.Add("Cercopithecoidea").Add("Cercopithecidae")
	hominoidea := catarrhini.Add("Hominoidea")
	hominoidea.Add("Hylobatidae")
	hominoidea.Add("Hominidae")

	return primate
}

The program below converts the result of find into a tree.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"

	"github.com/ddddddO/gtree"
)

// Example:
// $ cd github.com/ddddddO/gtree
// $ find . -type d -name .git -prune -o -type f -print
// ./config.go
// ./node_generator_test.go
// ./example/like_cli/adapter/indentation.go
// ./example/like_cli/adapter/executor.go
// ./example/like_cli/main.go
// ./example/find_pipe_programmable-gtree/main.go
// ...
// $ find . -type d -name .git -prune -o -type f -print | go run example/find_pipe_programmable-gtree/main.go
// << See "Output:" below. >>
func main() {
	var (
		root *gtree.Node
		node *gtree.Node
	)
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()              // e.g.) "./example/find_pipe_programmable-gtree/main.go"
		splited := strings.Split(line, "/") // e.g.) [. example find_pipe_programmable-gtree main.go]

		for i, s := range splited {
			if root == nil {
				root = gtree.NewRoot(s) // s := "."
				node = root
				continue
			}
			if i == 0 {
				continue
			}

			tmp := node.Add(s)
			node = tmp
		}
		node = root
	}

	if err := gtree.OutputProgrammably(os.Stdout, root); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// .
	// โ”œโ”€โ”€ config.go
	// โ”œโ”€โ”€ node_generator_test.go
	// โ”œโ”€โ”€ example
	// โ”‚   โ”œโ”€โ”€ like_cli
	// โ”‚   โ”‚   โ”œโ”€โ”€ adapter
	// โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ indentation.go
	// โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ executor.go
	// โ”‚   โ”‚   โ””โ”€โ”€ main.go
	// โ”‚   โ”œโ”€โ”€ find_pipe_programmable-gtree
	// โ”‚   โ”‚   โ””โ”€โ”€ main.go
	// โ”‚   โ”œโ”€โ”€ go-list_pipe_programmable-gtree
	// โ”‚   โ”‚   โ””โ”€โ”€ main.go
	// โ”‚   โ””โ”€โ”€ programmable
	// โ”‚       โ””โ”€โ”€ main.go
	// โ”œโ”€โ”€ file_considerer.go
	// โ”œโ”€โ”€ node.go
	// โ”œโ”€โ”€ node_generator.go
	// โ”œโ”€โ”€ .gitignore
	// ...
}

MkdirProgrammably func

package main

import (
	"fmt"

	"github.com/ddddddO/gtree"
)

func main() {
	primate := preparePrimate()
	if err := gtree.MkdirProgrammably(primate); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output(using Linux 'tree' command):
	// 22:20:43 > tree Primate/
	// Primate/
	// โ”œโ”€โ”€ Haplorrhini
	// โ”‚   โ”œโ”€โ”€ Simiiformes
	// โ”‚   โ”‚   โ”œโ”€โ”€ Catarrhini
	// โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Cercopithecoidea
	// โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Cercopithecidae
	// โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Hominoidea
	// โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ Hominidae
	// โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ Hylobatidae
	// โ”‚   โ”‚   โ””โ”€โ”€ Platyrrhini
	// โ”‚   โ”‚       โ”œโ”€โ”€ Ceboidea
	// โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Atelidae
	// โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ Cebidae
	// โ”‚   โ”‚       โ””โ”€โ”€ Pithecioidea
	// โ”‚   โ”‚           โ””โ”€โ”€ Pitheciidae
	// โ”‚   โ””โ”€โ”€ Tarsiiformes
	// โ”‚       โ””โ”€โ”€ Tarsiidae
	// โ””โ”€โ”€ Strepsirrhini
	// 	โ”œโ”€โ”€ Lemuriformes
	// 	โ”‚   โ”œโ”€โ”€ Daubentonioidea
	// 	โ”‚   โ”‚   โ””โ”€โ”€ Daubentoniidae
	// 	โ”‚   โ””โ”€โ”€ Lemuroidea
	// 	โ”‚       โ”œโ”€โ”€ Cheirogaleidae
	// 	โ”‚       โ”œโ”€โ”€ Indriidae
	// 	โ”‚       โ”œโ”€โ”€ Lemuridae
	// 	โ”‚       โ””โ”€โ”€ Lepilemuridae
	// 	โ””โ”€โ”€ Lorisiformes
	// 		โ”œโ”€โ”€ Galagidae
	// 		โ””โ”€โ”€ Lorisidae
	//
	// 28 directories, 0 files
}

details

Make directories and files with specific extensions.

package main

import (
	"fmt"

	"github.com/ddddddO/gtree"
)

func main() {
	gtreeDir := gtree.NewRoot("gtree")
	gtreeDir.Add("cmd").Add("gtree").Add("main.go")
	gtreeDir.Add("Makefile")
	testdataDir := gtreeDir.Add("testdata")
	testdataDir.Add("sample1.md")
	testdataDir.Add("sample2.md")
	gtreeDir.Add("tree.go")

	// make directories and files with specific extensions.
	if err := gtree.MkdirProgrammably(
		gtreeDir,
		gtree.WithFileExtensions([]string{".go", ".md", "Makefile"}),
	); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output(using Linux 'tree' command):
	// 09:44:50 > tree gtree/
	// gtree/
	// โ”œโ”€โ”€ cmd
	// โ”‚   โ””โ”€โ”€ gtree
	// โ”‚       โ””โ”€โ”€ main.go
	// โ”œโ”€โ”€ Makefile
	// โ”œโ”€โ”€ testdata
	// โ”‚   โ”œโ”€โ”€ sample1.md
	// โ”‚   โ””โ”€โ”€ sample2.md
	// โ””โ”€โ”€ tree.go
	//
	// 3 directories, 5 files
}

VerifyProgrammably func

You can use gtree.WithTargetDir func / gtree.WithStrictVerify func.

WalkProgrammably func

package main

import (
	"fmt"
	"os"

	"github.com/ddddddO/gtree"
)

func main() {
	root := gtree.NewRoot("root")
	root.Add("child 1").Add("child 2").Add("child 3")
	root.Add("child 5")
	root.Add("child 1").Add("child 2").Add("child 4")

	callback := func(wn *gtree.WalkerNode) error {
		fmt.Println(wn.Row())
		return nil
	}

	if err := gtree.WalkProgrammably(root, callback); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// root
	// โ”œโ”€โ”€ child 1
	// โ”‚   โ””โ”€โ”€ child 2
	// โ”‚       โ”œโ”€โ”€ child 3
	// โ”‚       โ””โ”€โ”€ child 4
	// โ””โ”€โ”€ child 5

	callback2 := func(wn *gtree.WalkerNode) error {
		fmt.Println("WalkerNode's methods called...")
		fmt.Printf("\tName     : %s\n", wn.Name())
		fmt.Printf("\tBranch   : %s\n", wn.Branch())
		fmt.Printf("\tRow      : %s\n", wn.Row())
		fmt.Printf("\tLevel    : %d\n", wn.Level())
		fmt.Printf("\tPath     : %s\n", wn.Path())
		fmt.Printf("\tHasChild : %t\n", wn.HasChild())
		return nil
	}

	if err := gtree.WalkProgrammably(root, callback2); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	// Output:
	// WalkerNode's methods called...
	//         Name     : root
	//         Branch   : 
	//         Row      : root
	//         Level    : 1
	//         Path     : root
	//         HasChild : true
	// WalkerNode's methods called...
	//         Name     : child 1
	//         Branch   : โ”œโ”€โ”€
	//         Row      : โ”œโ”€โ”€ child 1
	//         Level    : 2
	//         Path     : root/child 1
	//         HasChild : true
	// WalkerNode's methods called...
	//         Name     : child 2
	//         Branch   : โ”‚   โ””โ”€โ”€
	//         Row      : โ”‚   โ””โ”€โ”€ child 2
	//         Level    : 3
	//         Path     : root/child 1/child 2
	//         HasChild : true
	// WalkerNode's methods called...
	//         Name     : child 3
	//         Branch   : โ”‚       โ”œโ”€โ”€
	//         Row      : โ”‚       โ”œโ”€โ”€ child 3
	//         Level    : 4
	//         Path     : root/child 1/child 2/child 3
	//         HasChild : false
	// WalkerNode's methods called...
	//         Name     : child 4
	//         Branch   : โ”‚       โ””โ”€โ”€
	//         Row      : โ”‚       โ””โ”€โ”€ child 4
	//         Level    : 4
	//         Path     : root/child 1/child 2/child 4
	//         HasChild : false
	// WalkerNode's methods called...
	//         Name     : child 5
	//         Branch   : โ””โ”€โ”€
	//         Row      : โ””โ”€โ”€ child 5
	//         Level    : 2
	//         Path     : root/child 5
	//         HasChild : false
}

Process

Note

This process is for the Massive Roots mode.

Performance

Warning

Depends on the environment.

  • Comparison simple implementation and pipeline implementation.
  • In the case of few Roots, simple implementation is faster in execution!
    • Use this one by default.
  • However, for multiple Roots, pipeline implementation execution speed tends to be faster๐Ÿ’ชโœจ
    • In the CLI, it is available by specifying --massive.
    • In the Go program, it is available by specifying WithMassive func.

Benchmark log

Simple implementation

11:19:22 > go test -benchmem -bench Benchmark -benchtime 100x benchmark_simple_test.go
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
BenchmarkOutput_singleRoot-4                 100             35375 ns/op           13856 B/op        171 allocs/op
BenchmarkOutput_tenRoots-4                   100            200540 ns/op           72920 B/op       1597 allocs/op
BenchmarkOutput_fiftyRoots-4                 100            730156 ns/op          569851 B/op       7919 allocs/op
BenchmarkOutput_hundredRoots-4               100           1706493 ns/op         1714260 B/op      15820 allocs/op
BenchmarkOutput_fiveHundredsRoots-4          100          16412090 ns/op        32245140 B/op      79022 allocs/op
BenchmarkOutput_thousandRoots-4              100          55142492 ns/op        120929674 B/op    158025 allocs/op
BenchmarkOutput_3000Roots-4                  100         489121246 ns/op        1035617527 B/op   474029 allocs/op
BenchmarkOutput_6000Roots-4                  100        1613641261 ns/op        4087694372 B/op   948033 allocs/op
BenchmarkOutput_10000Roots-4                 100        3913090646 ns/op        11293191221 B/op         1580035 allocs/op
PASS
ok      command-line-arguments  614.944s

Pipeline implementation

11:29:43 > go test -benchmem -bench Benchmark -benchtime 100x benchmark_pipeline_test.go
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
BenchmarkOutput_pipeline_singleRoot-4                100            188706 ns/op           24236 B/op        300 allocs/op
BenchmarkOutput_pipeline_tenRoots-4                  100            367758 ns/op          115970 B/op       2186 allocs/op
BenchmarkOutput_pipeline_fiftyRoots-4                100            947879 ns/op          542188 B/op      10592 allocs/op
BenchmarkOutput_pipeline_hundredRoots-4              100           1711537 ns/op         1099636 B/op      21094 allocs/op
BenchmarkOutput_pipeline_fiveHundredsRoots-4         100           6892261 ns/op         5524905 B/op     105107 allocs/op
BenchmarkOutput_pipeline_thousandRoots-4             100          13100335 ns/op        11225942 B/op     210115 allocs/op
BenchmarkOutput_pipeline_3000Roots-4                 100          40694497 ns/op        33399766 B/op     630142 allocs/op
BenchmarkOutput_pipeline_6000Roots-4                 100          85807944 ns/op        66974524 B/op    1260171 allocs/op
BenchmarkOutput_pipeline_10000Roots-4                100         151486713 ns/op        113908462 B/op   2100208 allocs/op
PASS
ok      command-line-arguments  30.670s

Documents

English

Japanese

Test coverage

treemap

...generated by nikolaydubina/go-cover-treemap !

Star History

Star History Chart

Footnotes

  1. Gopher retrieved from egonelbre/gophers ! โ†ฉ

gtree's People

Contributors

ddddddo avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gtree's Issues

ใ‚ณใƒผใƒ‰ใ‹ใ‚‰ๅ‘ผใณๅ‡บใ—ใฆใ‚‚ใ‚‰ใ†ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็”Ÿๆˆ้–ขๆ•ฐใฎdry run

  • command

    • ใ“ใ‚Œใฏใ€--dry-runๆŒ‡ๅฎšใงใƒ€ใƒกใชnodeๅใ‚’ๆคœ็Ÿฅ๏ผˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใฎไฝœๆˆใฏไธ€ๅˆ‡ใ—ใชใ„๏ผ‰ & ใƒ€ใƒกใงใชใ‘ใ‚Œใฐtreeๅ‡บๅŠ›ใฎๅฎŸ่ฃ…ใงใ‚ˆใ„๏ผˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใฎไฝœๆˆใฏไธ€ๅˆ‡ใ—ใชใ„๏ผ‰
  • package

    • Mkdir func
      • commandใจๅŒใ˜ใงใ„ใ„
    • MkdirProgrammably func
      • ใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใงใƒ€ใƒกใชnodeๅๆคœ็Ÿฅใงใ‚จใƒฉใƒผ๏ผˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใฎไฝœๆˆใฏไธ€ๅˆ‡ใ—ใชใ„๏ผ‰
      • WithDryRun funcใŒไธŽใˆใ‚‰ใ‚ŒใŸใ‚‰treeใ‚’ๅ‡บๅŠ›ใ™ใ‚‹๏ผˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใฎไฝœๆˆใฏไธ€ๅˆ‡ใ—ใชใ„๏ผ‰

ใƒกใƒข

  • WithDryRunใฃใฆใƒ—ใƒญใ‚ฐใƒฉใƒ ใงๆ‰ฑใ†ใฎใฏๅพฎๅฆ™ใชๆฐ—ใŒใ™ใ‚‹ใ€‚ๅฎ‰ๅ…จใซใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็”Ÿๆˆใ™ใ‚‹ใพใงใซ2ๅ›žMkdirProgrammablyๅ‘ผใณๅ‡บใ™ใจใ„ใ†ใ“ใจใ ใ‹ใ‚‰ใ€ใ„ใฃใMkdirProgrammablyใงใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใงใƒใƒชใƒ‡ใƒผใ‚ทใƒงใƒณใ—ใŸใปใ†ใŒ่‰ฏใ•ใใ†
  • cliใŒไฝฟใฃใฆใ‚‹ใƒ‘ใƒƒใ‚ฑใƒผใ‚ธใ‚‚ๅค–้ƒจใซๅ…ฌ้–‹ใ—ใฆใ‚‹ใ‹ใ‚‰ใใ†ใ—ใŸๆ–นใŒใ„ใ„ใฎใ‹ใ‚‚ใ€ใ€

ๅ‡บๅŠ›ใ‚’Linux treeใ ใ‘ใซใ—ใŸใใชใ„

ใ‚คใƒณใ‚นใƒ‘ใ‚คใ‚ข๏ผšhttps://github.com/birchb1024/frangipanni

ไธŠใฎใƒชใƒใ‚ธใƒˆใƒชใฏCLIใจใ—ใฆๆไพ›ใ—ใฆใ„ใ‚‹ใ€‚
ExecuteProgrammablyใงใ€ๅ‡บๅŠ›ใฎใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆใ‚’้ธๆŠžใงใใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„ใ€‚jsonใจใ‹ใ€‚
grow/expandใ‚’ใ‚คใƒณใ‚ฟใƒ•ใ‚งใƒผใ‚นใจใ—ใฆๅฎš็พฉใ—ใฆใ€Linux tree / json ใชใฉใฎใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆใงๅ‡บๅŠ›ใงใใ‚‹ใ‚ˆใ†ใชๅฎŸ่ฃ…ใ‚’ๆ›ธใใ€‚

ๆ™‚้–“ใŒใŸใถใ‚“ใ‹ใชใ‚Šใ‹ใ‹ใ‚Šใใ†ใชใฎใงใƒกใƒขใ ใ‘ใ€‚

nodejsใ‹ใ‚‰ใ‚‚ๅ‘ผใณๅ‡บใ›ใ‚‹ใ‚ˆใ†ใซใ™ใ‚‹

ไปฅไธ‹ใซใƒ’ใƒณใƒˆใŒๆ›ธใ„ใฆใ‚ใ‚‹

npmใƒ‘ใƒƒใ‚ฑใƒผใ‚ธใจใ—ใฆๅ…ฌ้–‹ใ—ใŸใ„

npm CLI toolใจใ—ใฆๅ…ฌ้–‹ใ—ใŸใ„

Web siteใฎdescriptionใŒๆคœ็ดข็ตๆžœใซๅๆ˜ ใ•ใ‚Œใชใ„

site:https://ddddddo.github.io/gtree/ ใงใ‚ฐใ‚ฐใ‚‹ใจใ€ไปฅไธ‹ใฎdescriptionใŒ่กจ็คบใ•ใ‚Œใ‚‹ใ€‚
textareaใฎไธ€้ƒจใฎๅ†…ๅฎนใŒ่กจ็คบใ•ใ‚Œใฆใ„ใ‚‹ใŸใ‚ใ€ไปฅไธ‹ใฎๆ–‡ๅญ—ๆ•ฐๅ†…ใงๆคœ็ดขใซใƒ’ใƒƒใƒˆใ—ใ‚„ใ™ใ„ใ‚ญใƒผใƒฏใƒผใƒ‰ใ‚’textareaใซๅ…ฅใ‚Œใฆใฟใ‚‹ใ€‚

Primate - Strepsirrhini - Lemuriformes - Lemuroidea - Cheirogaleidae - Indriidae - Lemuridae - Lepilemuridae - Daubentonioidea - Daubentoniidae ...

โ†“

Output tree from Markdown. - ๆ‰‹ไฝœๆฅญใงๆžใ‚’็ต„ใฟ็ซ‹ใฆใ‚‹ใฎใฏ้ขๅ€’ใ€ - ๆฅฝใซใƒ„ใƒชใƒผ(treeใ‚ณใƒžใƒณใƒ‰(Linux/Windows)็ตๆžœใฎใ‚ˆใ†ใชใƒ†ใ‚ญใ‚นใƒˆ) - ใ‚’ไฝœใ‚ŠใŸใ„ๆ™‚ใซๅฝนใซ็ซ‹ใกใพใ™ใ€‚ - ๆžใ‚’ๅค‰ใˆใ‚‰ใ‚Œใพใ™ใ€‚

ใƒ‘ใƒƒใ‚ฑใƒผใ‚ธใ‚’ๅˆ‡ใ‚ŠใŸใ„

  • Node structใŒใ€publicใงใ‹ใคใ‚ณใƒผใƒ‰ใฎใ‚ใกใ“ใกใงไฝฟใ‚ใ‚Œใฆใ‚‹ใฎใงใ€ใใ“ใ‚’ไฝ•ใจใ‹ใ™ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ใ€‚
    • ใ“ใฎgtreeใƒ‘ใƒƒใ‚ฑใƒผใ‚ธใ‚’ไฝฟใ†ไบบใซๅ…ฌ้–‹ใ—ใŸใ„ใ‚‚ใฎใฏใƒซใƒผใƒˆใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็›ดไธ‹ใซ็ฝฎใ„ใฆใŠใ„ใฆใ„ใ„
    • ใ“ใฎgtreeๅ†…้ƒจใงใฎใฟNodeใ‚’ไฝฟใฃใฆใ„ใ‚‹ใจใ“ใ‚ใฏinterface่ถŠใ—ใซๅ‘ผใณๅ‡บใ™ใ‚ˆใ†ใซใ—ใŸใ„
  • ้–ข้€ฃ

ใƒกใ‚ฝใƒƒใƒ‰ใƒใ‚งใƒผใƒณใฎๆ–นใŒ่‰ฏใ•ใใ†ใซๆ€ใˆใฆใใŸ

WithXxxxใฎ้–ขๆ•ฐใ‚’ไปฅไธ‹ใชๆ„Ÿใ˜ใงๅ‘ผใณๅ‡บใ—ใŸใ„

  • ใ‹ใฃใ“ใ„ใ„
  • packageๅใ„ใกใ„ใกๆ›ธใ‹ใชใใฆๆธˆใ‚€
    • ใ‚จใƒ‡ใ‚ฃใ‚ฟใง็ถšใ‘ใฆใƒกใ‚ฝใƒƒใƒ‰ใฎๅ€™่ฃœใจใ—ใฆๅ‡บใ—ใฆใใ‚Œใ‚‹
  • ไปŠใฎๅฎŸ่ฃ…ใจๅพŒๆ–นไบ’ๆ›ๆ€งใŒใชใ„
    • ๆ—ขๅญ˜ใฎ้–ขๆ•ฐใฏdeprecatedใจใƒžใƒผใ‚ฏใ—ใฆไธ€ๅฎšๆœŸ้–“ๆฎ‹ใ™
    • ๆ–ฐ้–ขๆ•ฐใฏๅ‘ฝๅๅค‰ใˆใฆๅฎš็พฉ
	err := gtree.OutputProgrammably(os.Stdout, root).
		WithBranchFormatIntermedialNode("+--", ":   ").
		WithBranchFormatLastNode("+--", "    ").
		Do()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

ใƒฆใƒผใ‚ถใƒผใŒMarkdownใ‚’ๅฎš็พฉใ—ใฆtemplateใ‚ตใƒ–ใ‚ณใƒžใƒณใƒ‰ใชใฉใงๅ‡บๅŠ›ใงใใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„

ๆกˆ

  • โ‘ ใƒ›ใƒผใƒ ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชไปฅไธ‹ใซconfigใƒ•ใ‚กใ‚คใƒซใ‚’็ฝฎใ„ใฆใ€gtree template xxxใฎใ‚ˆใ†ใซๅฎŸ่กŒใ™ใ‚‹ใจๅฎš็พฉใ•ใ‚ŒใŸMarkdownใ‚’ๅ‡บๅŠ›ใ™ใ‚‹

้›‘ใซmarkdown้ฃŸใ‚ใ›ใฆใ‚‚ๅ‡บๅŠ›ใงใใŸๆ–นใŒใ„ใ„ใฎใงใฏใชใ„ใ‹๏ผŸ

ใƒžใƒผใ‚ฏใƒ€ใ‚ฆใƒณใƒ‘ใƒผใ‚ตใ‚’ไธ€ๅฟœไฝœใฃใŸใฎใงใ€ๅฏพๅฟœใ—ใฆใชใ„่กŒใŒใใŸใ‚‰ใ€ใใ‚Œใจใ‚ใ‹ใ‚‹ใ‚จใƒฉใƒผ่ฟ”ใ—ใฆใ€ๅ‘ผใณๅ‡บใ—ๅ…ƒใงใ‚นใ‚ญใƒƒใƒ—ใ•ใ›ใฆใ„ใ„ใ‚“ใงใชใ„ใ‹

descriptionใŒๅˆ†ใ‹ใ‚Šใฅใ‚‰ใ„

ใจใ‚ณใƒกใƒณใƒˆใ‚’ใ‚‚ใ‚‰ใฃใŸใ€‚
https://www.reddit.com/r/programming/comments/sa1uw1/comment/htrxvqf/?utm_source=share&utm_medium=web2x&context=3
ๅ ดๅˆใซใ‚ˆใฃใฆใฏใ€้–ขๆ•ฐๅใƒปใƒกใ‚ฝใƒƒใƒ‰ๅใ‚‚ๅˆใ‚ใ›ใฆๅค‰ใˆใŸๆ–นใŒใ„ใ„ใ‹ใ‚‚ใ€‚

ใ‚ใจใ€ใ“ใฎใƒ„ใƒผใƒซ๏ผˆใƒ‘ใƒƒใ‚ฑใƒผใ‚ธ๏ผ‰ใฎๅˆฉ็‚นใƒปใƒฆใƒผใ‚นใ‚ฑใƒผใ‚นใฏใชใซใ‹ใ‚’descriptionใซ่จ˜่ผ‰ใ—ใŸๆ–นใŒใ„ใ„ใ‹ใ‚‚ใ—ใ‚Œใชใ„ใ€‚

textareaใซMarkdownใ‚’่ฒผใ‚Šไป˜ใ‘ใŸๅ ดๅˆใซใ‚ˆใ—ใชใซMarkdownใ‚’ใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆใ—ใฆใใ‚Œใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„

tree! ใƒœใ‚ฟใƒณๆŠผไธ‹ๆ™‚ใซใ€treeๅ‡บๅŠ›ใ™ใ‚‹้–ขๆ•ฐใซๅ…ฅๅŠ›ใ‚’ๆธกใ™ๅ‰ใซใ€ใ„ใ„ๆ„Ÿใ˜ใซใƒ•ใ‚ฉใƒผใƒžใƒƒใƒˆใงใใ‚‹ไฝ•ใ‹ใ‚’ๅฐŽๅ…ฅใ—ใŸใ„

dry-runใ—ใŸใจใใ€ใฉใ‚ŒใŒใƒ•ใ‚กใ‚คใƒซใƒปใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใ‹ใ‚ใ‹ใ‚‹ใ‚ˆใ†ใซ่‰ฒใ‚’ไป˜ใ‘ใŸใ„

  • ใƒ•ใ‚กใ‚คใƒซๅ‡บๅŠ›ๆ™‚ใซ่‰ฒใฎๆ–‡ๅญ—ๅˆ—ใฏใ„ใ‚‰ใชใ„ใ‹ -> ๅ…ฅใฃใฆใ—ใพใ†
/mnt/c/DEV/workspace/GO/src/github.com/ddddddO/work/go/color
11:20:36 > go run main.go > tmp

ใงtmpใฎไธญ่บซ

๏ฟฝ[30mHello, world!๏ฟฝ[0m
๏ฟฝ[31mHello, world!๏ฟฝ[0m
๏ฟฝ[32mHello, world!๏ฟฝ[0m
๏ฟฝ[33mHello, world!๏ฟฝ[0m
๏ฟฝ[34mHello, world!๏ฟฝ[0m
๏ฟฝ[35mHello, world!๏ฟฝ[0m
๏ฟฝ[36mHello, world!๏ฟฝ[0m
๏ฟฝ[37mHello, world!๏ฟฝ[0m
  • osๆฏŽใซๅฎŸ่ฃ…ๅค‰ใˆใชใ„ใจใ„ใ‘ใชใ‹ใฃใŸใ‚Šใ™ใ‚‹ใ‹๏ผŸ
  • ใ‚ณใƒผใƒ‰ใ‹ใ‚‰ๅ‘ผใณๅ‡บใ™้–ขๆ•ฐใฎๅ ดๅˆใฏใฉใ†ใ™ใ‚‹ใ‹๏ผŸ

Markdownใƒ‘ใƒผใ‚ตใƒผใ‚’ไฝœใ‚ŠใŸใ„

  • ๅ…ฅๅŠ›ใจใ—ใฆๅฏพๅฟœใ—ใฆใ„ใ‚‹ใฎใŒMarkdownใฎ - ใฎใฟใชใฎใงใ€ไป–ใฎ่จ˜ๆณ•ใ‚‚ๅฏพๅฟœใ—ใŸใ„
  • ๆง‹ๆ–‡่งฃๆžๅ™จใ‚’ไฝœใ‚ŠใŸใ„

type Node structใฎpublicใƒ•ใ‚ฃใƒผใƒซใƒ‰ใ‚’ใ‚„ใ‚ใŸใ„

json/toml/yamlใซใ‚จใƒณใ‚ณใƒผใƒ‰ใ™ใ‚‹ใจใใซใƒ•ใ‚ฃใƒผใƒซใƒ‰ใŒpublicใงใชใ„ใจใƒ€ใƒกใชใฎใงไปŠใฏใใ†ใ—ใฆใ„ใ‚‹ใŒใ€ใใ‚Œใ‚’ใ‚„ใ‚ใŸใ„ใ€‚
json/toml/yaml็”จใฎNode็”จstructใ‚’ๅฎš็พฉใ—ใฆใ€ใใฎใƒ•ใ‚ฃใƒผใƒซใƒ‰ใ‚’publicใซใ—ใฆNodeใ‚’่ฉฐใ‚ๆ›ฟใˆใ‚Œใฐๅฏ่ƒฝใใ†ใ€‚
ใŸใ ใ€NodeใŒ่‡ชๅทฑๅ‚็…งๅž‹ใฎstructใชใŸใ‚ใ€้ขๅ€’ใ€‚

ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็”ŸๆˆๆฉŸ่ƒฝ

  • documentๆ›ดๆ–ฐ
    • README
      • ๅ„็จฎREADME
      • v1.2.4ใ‹ใ‚‰้žไบ’ๆ›ใงใ‚ใ‚‹ใ“ใจใ‚’ๆ˜Ž่จ˜
      • dry-runใงๅ‡บๅŠ›ใ•ใ‚Œใ‚‹ใƒ„ใƒชใƒผใจๅฎŸ้š›ใซไฝœๆˆใ•ใ‚Œใ‚‹ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒชใงใฏใ‚ฝใƒผใƒˆใฎๆœ‰็„กใŒใ‚ใ‚‹ใ“ใจใ‚’ๆ˜Ž่จ˜
    • godoc
      • ๅ…ฌ้–‹ใƒกใ‚ฝใƒƒใƒ‰ใƒปใƒ•ใ‚ฃใƒผใƒซใƒ‰ใซใ‚ณใƒกใƒณใƒˆใคใ‘ใ‚‹
    • zenn
    • awesome-goใซPRๆŠ•ใ’ใ‚‹
    • githubไธŠใฎabout
  • ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็”ŸๆˆๆฉŸ่ƒฝ่ฟฝๅŠ 
  • [Only programable]ๅ„NodeๆฏŽใซใƒฆใƒผใ‚ถใƒผๅฎš็พฉ้–ขๆ•ฐใ‚’ๅฎŸ่กŒใงใใ‚‹ใ‚ˆใ†ใซใ™ใ‚‹ ใฉใ“ใงๅฎŸ่กŒใ•ใ›ใ‚‹ใ‹ใงใฆใ“ใชใ‹ใฃใŸ
    • Nodeใƒกใ‚ฝใƒƒใƒ‰ใฎๅ…ฌ้–‹ใƒปใ‚ใ‚‹ใจ่‰ฏใ•ใใ†ใชใƒกใ‚ฝใƒƒใƒ‰่ฟฝๅŠ 
  • ใ‚ณใƒžใƒณใƒ‰ใƒฉใ‚คใƒณใƒ•ใƒฉใ‚ฐใŒ่ค‡้›‘ใซใชใฃใฆใใฆใ‚‹ใ‹ใ‚‰github.com/urfave/cli/v2ไฝฟใ†
    • treeๅ‡บๅŠ›ใƒขใƒผใƒ‰
      • stdout or yaml or toml ro json
    • ใƒ‡ใ‚ฃใƒฌใ‚ฏใƒˆใƒช็”Ÿๆˆใƒขใƒผใƒ‰
      • dry run
      • ็”Ÿๆˆ
    • helpใ‚’ๅ……ๅฎŸใ•ใ›ใ‚‹ใฎใจใ€ๅ…ฅๅŠ›ใซใชใ‚‹Markdownใฎใƒ†ใƒณใƒ—ใƒฌใƒผใƒˆๅ‡บๅŠ›ใ™ใ‚‹ใฎใ‚‚ใ„ใ„ใ‹ใ‚‚
    • ใƒ•ใƒฉใ‚ฐใฎใƒ‡ใƒ•ใ‚ฉใƒซใƒˆๅ€คใ‚’่จญๅฎšใ™ใ‚‹ใ€‚helpใงๅ‡บๅŠ›ใ—ใŸใจใใ€ไฝ•ใŒใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใ‹ใ‚ใ‹ใ‚‰ใชใ„ใ€ไพ‹ใˆใฐmarkdownใฎใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใŒtabใงใ‚ใ‚‹ใจใ‹
  • ใƒชใƒ•ใ‚กใ‚ฏใ‚ฟ
    • option func ใฎใƒ—ใƒฌใƒ•ใ‚ฃใƒƒใ‚ฏใ‚นใซWithใคใ‘ใ‚‹
    • ใ‚ณใƒกใƒณใƒˆๅ…จ้ƒจ่‹ฑ่ชžใซใ™ใ‚‹
    • ไธ้ฉๅฝ“ใชใƒใƒผใƒŸใƒณใ‚ฐใชใฉ
  • ใƒ†ใ‚นใƒˆ

Node structใ‚’้–ขๅฟƒใฎๅˆ†้›ขใ•ใ›ใฆใฟใ‚‹

ไปฅไธ‹ใฎใ‚คใƒกใƒผใ‚ธ

  • tree_grow.go: Nodeใ‚’ใใฎใพใพไฝฟใ†
  • tree_spread.go: Node -> SpreadNodeใชstructใซๅค‰ๆ›ใ—ใŸใ‚‚ใฎใ‚’ไฝฟใ†
  • tree_mkdir.go: Node -> MkdirNodeใชstructใซๅค‰ๆ›ใ—ใŸใ‚‚ใฎใ‚’ไฝฟใ†

ใƒชใƒ•ใ‚กใ‚ฏใ‚ฟ

  • ใƒ•ใ‚กใ‚คใƒซๅใŒๅ‹•่ฉžใง็ต‚ใ‚ใฃใฆใ„ใ‚‹ใ‚‚ใฎใซใฏerใ‚’ใคใ‘ใ‚‹
  • initializeTreeใงใฏใชใใ€newTreeใงใ„ใ„
    • grow,spread,mkdir็”จใฎabstract factory้–ขๆ•ฐไฝœใฃใฆnewTreeใงๅ‘ผใณๅ‡บใ™ใ‚ˆใ†ใซใ™ใ‚‹ใ€ใ‹ใ‚‚ใ€‚ๅ†—้•ทๆ„Ÿใ‚ใ‚‹ใ€‚
  • grow,spread,mkdir็”จinterfaceใฏtree.goใซ็งปๅ‹•ใ—ใŸๆ–นใŒใ„ใ„ใ‹ใชใใจๆ€ใฃใฆใใŸใ€‚

mkdirใ‚ตใƒ–ใ‚ณใƒžใƒณใƒ‰ๅฎŸ่กŒๆ™‚ใจdryrunใƒ•ใƒฉใ‚ฐไป˜ใๅฎŸ่กŒๆ™‚ใจใง็ตๆžœใŒ็•ฐใชใ‚‹

  • ๅŒใ˜่ฆชใฎไธ‹ใซๅŒใ˜ๅๅ‰ใฎnodeใŒๅŒใ˜้šŽๅฑคใซใ„ใ‚‹ใฎใŒๅŽŸๅ› ใ€‚ใฉใ†ใ—ใ‚ˆใ†ใ€‚ๆจ™ๆบ–ๅ‡บๅŠ›ไปฅๅค–ๅ•้กŒใฏใชใ„ใ‘ใฉ็›ดใ›ใ‚‹ใชใ‚‰็›ดใ—ใŸใ„ใ€‚
19:46:02 > cat testdata/sample2.md | gtree mkdir --dry-run
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)

21 directories, 0 files
19:46:10 > cat testdata/sample2.md | gtree mkdir
/mnt/c/DEV/workspace/GO/src/github.com/ddddddO/gtree
19:50:39 > tree k8s_resources/
k8s_resources/
โ”œโ”€โ”€ (Tier3)
โ”‚   โ””โ”€โ”€ (Tier2)
โ”‚       โ””โ”€โ”€ (Tier1)
โ”‚           โ””โ”€โ”€ (Tier0)
โ”œโ”€โ”€ (empty)
โ”‚   โ”œโ”€โ”€ DaemonSet
โ”‚   โ”‚   โ””โ”€โ”€ Pod
โ”‚   โ”‚       โ””โ”€โ”€ container(s)
โ”‚   โ””โ”€โ”€ StatefulSet
โ”‚       โ””โ”€โ”€ Pod
โ”‚           โ””โ”€โ”€ container(s)
โ”œโ”€โ”€ CronJob
โ”‚   โ””โ”€โ”€ Job
โ”‚       โ””โ”€โ”€ Pod
โ”‚           โ””โ”€โ”€ container(s)
โ””โ”€โ”€ Deployment
    โ””โ”€โ”€ ReplicaSet
        โ””โ”€โ”€ Pod
            โ””โ”€โ”€ container(s)

19 directories, 0 files

redditใฎwebdevใธๅฎฃไผใ™ใ‚‹

  • title: Tree Maker __ Convert markdown to tree!
  • tags: OC, ShowoffSaturday
  • image&video: web_example.gif

โ†“
ไปฅไธ‹ใ‚’ใ‚ณใƒกใƒณใƒˆใงๆŠ•็จฟ

The link to this website is https://ddddddo.github.io/gtree/

Usage is as follows.
- The symbols that can be used in Markdown are *, -, +, and #.
- Use every two spaces to represent a hierarchy.

This website features.
- The function to generate tree is written in Go and compiled to WebAssembly.
- It uses ServiceWorker, so you can load it once and then enjoy it offline!

I provide not only website, but also CLI tool and Go package. These also have the ability to generate directories from markdown!
The repository is https://github.com/ddddddO/gtree
I'd love it if you'd star it!

node_generate_strategy.goใฎๅ„ใƒกใ‚ฝใƒƒใƒ‰ใŒ่ค‡้›‘

11:13:26 > gocognito --over=10 .
/mnt/c/DEV/workspace/GO/src/github.com/ddddddO/gtree/node_generate_strategy.go:40:1: func (*tabStrategy).generate cognitive complexity: 15
/mnt/c/DEV/workspace/GO/src/github.com/ddddddO/gtree/node_generate_strategy.go:89:1: func (*twoSpacesStrategy).generate cognitive complexity: 15
/mnt/c/DEV/workspace/GO/src/github.com/ddddddO/gtree/node_generate_strategy.go:136:1: func (*fourSpacesStrategy).generate cognitive complexity: 15
  • ๅ„generateใƒกใ‚ฝใƒƒใƒ‰ใงใ€่กŒใ”ใจใซๆœ€ๅพŒใฎๆ–‡ๅญ—ใพใงใƒใ‚งใƒƒใ‚ฏใ—ใฆhierarchyใจtextใ‚’่จˆ็ฎ—ใ—ใฆใ„ใ‚‹ใŒใ€ใ‚‚ใฃใจ็ฐก็ด ใซใงใใชใ„ใ‹
    • hierarchyใพใง่จˆ็ฎ—ใงใใ‚Œใฐใ€ใ‚ใจใฏrow[startText: len(row)]ใงtextใจใ—ใฆๅ‡ฆ็†ใ‚’ๅˆ†ๅ‰ฒใงใใใ†ใชๆฐ—ใŒใ—ใŸใ€‚
    • node_generate_strategy_test.go ใซใƒ†ใ‚นใƒˆใ‚’่ฟฝๅŠ ใ—ใคใคๅค‰ๆ›ดใ™ใ‚‹

encode MessagePack


19:39:13 > go install github.com/nokute78/msgpack-microscope/cmd/msgpack2json@latest
19:40:53 > cat testdata/sample1.md | go run cmd/gtree/main.go -m | msgpack2json
{"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a161a86368696c6472656e9482a576616c7565a3767676a86368696c6472656e9182a576616c7565a36a6a6aa86368696c6472656ec082a576616c7565a46b676767a86368696c6472656e9282a576616c7565a46b6b6464a86368696c6472656ec082a576616c7565a474676767a86368696c6472656ec082a576616c7565a56564646464a86368696c6472656e9182a576616c7565a46f727272a86368696c6472656ec082a576616c7565a467676767a86368696c6472656ec0", "value":
    [
        {"key":
            {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
         "value":
            {"format":"fixstr", "header":"0xa1", "raw":"0xa161", "value":"a"}
        },
        {"key":
            {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
         "value":
            {"format":"fixarray", "header":"0x94", "length":4, "raw":"0x9482a576616c7565a3767676a86368696c6472656e9182a576616c7565a36a6a6aa86368696c6472656ec082a576616c7565a46b676767a86368696c6472656e9282a576616c7565a46b6b6464a86368696c6472656ec082a576616c7565a474676767a86368696c6472656ec082a576616c7565a56564646464a86368696c6472656e9182a576616c7565a46f727272a86368696c6472656ec082a576616c7565a467676767a86368696c6472656ec0", "value":
                [
                    {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a3767676a86368696c6472656e9182a576616c7565a36a6a6aa86368696c6472656ec0", "value":
                        [
                            {"key":
                                {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                             "value":
                                {"format":"fixstr", "header":"0xa3", "raw":"0xa3767676", "value":"vvv"}
                            },
                            {"key":
                                {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                             "value":
                                {"format":"fixarray", "header":"0x91", "length":1, "raw":"0x9182a576616c7565a36a6a6aa86368696c6472656ec0", "value":
                                    [
                                        {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a36a6a6aa86368696c6472656ec0", "value":
                                            [
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                                                 "value":
                                                    {"format":"fixstr", "header":"0xa3", "raw":"0xa36a6a6a", "value":"jjj"}
                                                },
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                                                 "value":
                                                    {"format":"nil", "header":"0xc0", "raw":"0xc0", "value":null}
                                                }
                                            ]
                                        }
                                    ]
                                }

                            }
                        ]
                    },
                    {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a46b676767a86368696c6472656e9282a576616c7565a46b6b6464a86368696c6472656ec082a576616c7565a474676767a86368696c6472656ec0", "value":
                        [
                            {"key":
                                {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                             "value":
                                {"format":"fixstr", "header":"0xa4", "raw":"0xa46b676767", "value":"kggg"}
                            },
                            {"key":
                                {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                             "value":
                                {"format":"fixarray", "header":"0x92", "length":2, "raw":"0x9282a576616c7565a46b6b6464a86368696c6472656ec082a576616c7565a474676767a86368696c6472656ec0", "value":
                                    [
                                        {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a46b6b6464a86368696c6472656ec0", "value":
                                            [
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                                                 "value":
                                                    {"format":"fixstr", "header":"0xa4", "raw":"0xa46b6b6464", "value":"kkdd"}
                                                },
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                                                 "value":
                                                    {"format":"nil", "header":"0xc0", "raw":"0xc0", "value":null}
                                                }
                                            ]
                                        },
                                        {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a474676767a86368696c6472656ec0", "value":
                                            [
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                                                 "value":
                                                    {"format":"fixstr", "header":"0xa4", "raw":"0xa474676767", "value":"tggg"}
                                                },
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                                                 "value":
                                                    {"format":"nil", "header":"0xc0", "raw":"0xc0", "value":null}
                                                }
                                            ]
                                        }
                                    ]
                                }

                            }
                        ]
                    },
                    {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a56564646464a86368696c6472656e9182a576616c7565a46f727272a86368696c6472656ec0", "value":
                        [
                            {"key":
                                {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                             "value":
                                {"format":"fixstr", "header":"0xa5", "raw":"0xa56564646464", "value":"edddd"}
                            },
                            {"key":
                                {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                             "value":
                                {"format":"fixarray", "header":"0x91", "length":1, "raw":"0x9182a576616c7565a46f727272a86368696c6472656ec0", "value":
                                    [
                                        {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a46f727272a86368696c6472656ec0", "value":
                                            [
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                                                 "value":
                                                    {"format":"fixstr", "header":"0xa4", "raw":"0xa46f727272", "value":"orrr"}
                                                },
                                                {"key":
                                                    {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                                                 "value":
                                                    {"format":"nil", "header":"0xc0", "raw":"0xc0", "value":null}
                                                }
                                            ]
                                        }
                                    ]
                                }

                            }
                        ]
                    },
                    {"format":"fixmap", "header":"0x82", "length":2, "raw":"0x82a576616c7565a467676767a86368696c6472656ec0", "value":
                        [
                            {"key":
                                {"format":"fixstr", "header":"0xa5", "raw":"0xa576616c7565", "value":"value"},
                             "value":
                                {"format":"fixstr", "header":"0xa4", "raw":"0xa467676767", "value":"gggg"}
                            },
                            {"key":
                                {"format":"fixstr", "header":"0xa8", "raw":"0xa86368696c6472656e", "value":"children"},
                             "value":
                                {"format":"nil", "header":"0xc0", "raw":"0xc0", "value":null}
                            }
                        ]
                    }
                ]
            }

        }
    ]
}

19:41:15 > cat testdata/sample1.md 
- a
        - vvv
                - jjj
        - kggg
                - kkdd
                - tggg
        - edddd
                - orrr
        - gggg

Windowsใƒฆใƒผใ‚ถใƒผๅ‘ใ‘ใซScoopใงใ‚คใƒณใ‚นใƒˆใƒผใƒซใงใใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„

ใ‚คใƒณใƒ—ใƒƒใƒˆใฎใƒ•ใ‚กใ‚คใƒซใ‚’็›ฃ่ฆ–ใ—ใฆใƒ„ใƒชใƒผใ‚’็”Ÿๆˆใ™ใ‚‹

Webใƒšใƒผใ‚ธ้–‹ใ„ใฆtree!ๆŠผไธ‹ใงใƒ„ใƒชใƒผๅ‡บๅŠ›ใ—ใชใ„ไบ‹ใŒใ‚ใ‚‹

  • ใใ‚Œใพใงใใ‚“ใชๆŒ™ๅ‹•ใ—ใฆใชใ‹ใฃใŸใ‹ใ‚‰ใ€gtree-wasm้…ไธ‹ใฎใ‚ณใƒŸใƒƒใƒˆๅฑฅๆญด่ชฟในใ‚‹
  • firefox, edgeใฏๅคงไธˆๅคซใใ†ใ€‚ใƒ—ใƒฉใ‚คใƒ™ใƒผใƒˆใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใง็ขบ่ชใ—ใŸใ€‚chromeใ ใ‘๏ผŸ
    • edge, chromeใฏใ€https://github.com/ddddddO/gtree ใ‹ใ‚‰้ท็งปใ™ใ‚‹ใจใƒ€ใƒกใฟใŸใ„ใ€‚ใƒ—ใƒฉใ‚คใƒ™ใƒผใƒˆใ‚ฆใ‚ฃใƒณใƒ‰ใ‚ฆใง็ขบ่ชใ—ใŸใ€‚

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.