Skip to content

Commit

Permalink
For setting up sample project by gonew command (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddddO committed Sep 10, 2023
1 parent 9d9a9bc commit a201239
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Provide CLI, Golang library and Web.
- **[CLI](https://github.com/ddddddO/gtree#cli)**
- **[Library - used in Web and CLI](https://github.com/ddddddO/gtree#library---used-in-web-and-cli)**
- **[Library - programmable tree structure](https://github.com/ddddddO/gtree#library---programmable-tree-structure)**
- You can set up sample project with the `gonew` command. See [`it`](example/README.md).


# Web
Expand Down Expand Up @@ -484,9 +485,16 @@ OPTIONS:
```console
$ 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
Expand All @@ -498,12 +506,19 @@ example
└── programmable
└── main.go

6 directories, 7 files
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
Expand Down Expand Up @@ -639,6 +654,10 @@ You can use `gtree.WithTargetDir` func / `gtree.WithStrictVerify` func.

# Library - programmable tree structure

> **Note**<br>
> The `gonew` command can be used to set up sample project using gtree library.<br>
> See [here](example/README.md) for details.
## Installation

Go version requires 1.18 or later.
Expand Down
50 changes: 50 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Templates for project using *`gtree`* library

You can set up either project with `gonew` command.<br>
The gtree library of each project generates programmable tree structure and outputs tree based on it to standard output.

## Templates
- *find_pipe_programmable-gtree*
- This is simple program that outputs results of `find` command execution in tree.
- Please refer to [README](find_pipe_programmable-gtree/README.md) for details.

- *go-list_pipe_programmable-gtree*
- This is simple program that outputs results of '`go list -deps`' command execution in tree.
- Please refer to [README](go-list_pipe_programmable-gtree/README.md) for details.

## Using Templates

### 1. Install [`gonew`](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command

```console
$ go install golang.org/x/tools/cmd/gonew@latest
```

### 2. Clone by specifying template

```console
$ gonew github.com/ddddddO/example/find_pipe_programmable-gtree
```

or

```console
$ gonew github.com/ddddddO/example/go-list_pipe_programmable-gtree
```

### 3. Run the program
#### For *find_pipe_programmable-gtree*
```console
$ find . -type d -name .git -prune -o -type f -print | go run main.go
```

... You may have felt that the result of executing the find command in the project root was not enough. If so, try executing it in a place with many directories!

#### For *go-list_pipe_programmable-gtree*
```console
$ go list -deps . | go run main.go
```

### 4. Arrange the program to your liking!

Thanks for reading to the end!
29 changes: 29 additions & 0 deletions example/find_pipe_programmable-gtree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# *find_pipe_programmable-gtree*

This is simple program that outputs results of `find` command execution in tree.

## Using Templates

### 1. Install [`gonew`](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command

```console
$ go install golang.org/x/tools/cmd/gonew@latest
```

### 2. Clone by specifying template

```console
$ gonew github.com/ddddddO/example/find_pipe_programmable-gtree
```

### 3. Run the program

```console
$ find . -type d -name .git -prune -o -type f -print | go run main.go
```

... You may have felt that the result of executing the find command in the project root was not enough. If so, try executing it in a place with many directories!

### 4. Arrange the program to your liking!

Thanks for reading to the end!
15 changes: 15 additions & 0 deletions example/find_pipe_programmable-gtree/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module example/find_pipe_programmable-gtree

go 1.21.0

require github.com/ddddddO/gtree v1.9.9

require (
github.com/fatih/color v1.15.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
35 changes: 35 additions & 0 deletions example/find_pipe_programmable-gtree/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ddddddO/gtree v1.9.9 h1:hkQ1v4spu80aUFLleaLJbu05GuMwKdySAf8e7JOOQe8=
github.com/ddddddO/gtree v1.9.9/go.mod h1:bBogFFA4bLxu3gUuD4ozIxZBTt6VQvncxEfzEo57XP0=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
27 changes: 27 additions & 0 deletions example/go-list_pipe_programmable-gtree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# *go-list_pipe_programmable-gtree*

This is simple program that outputs results of '`go list -deps`' command execution in tree.

## Using Templates

### 1. Install [`gonew`](https://pkg.go.dev/golang.org/x/tools/cmd/gonew) command

```console
$ go install golang.org/x/tools/cmd/gonew@latest
```

### 2. Clone by specifying template

```console
$ gonew github.com/ddddddO/example/go-list_pipe_programmable-gtree
```

### 3. Run the program

```console
$ go list -deps . | go run main.go
```

### 4. Arrange the program to your liking!

Thanks for reading to the end!
15 changes: 15 additions & 0 deletions example/go-list_pipe_programmable-gtree/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module example/go-list_pipe_programmable-gtree

go 1.21.0

require github.com/ddddddO/gtree v1.9.9

require (
github.com/fatih/color v1.15.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
35 changes: 35 additions & 0 deletions example/go-list_pipe_programmable-gtree/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ddddddO/gtree v1.9.9 h1:hkQ1v4spu80aUFLleaLJbu05GuMwKdySAf8e7JOOQe8=
github.com/ddddddO/gtree v1.9.9/go.mod h1:bBogFFA4bLxu3gUuD4ozIxZBTt6VQvncxEfzEo57XP0=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 7 additions & 0 deletions testdata/sample9.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
- 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
Expand Down

0 comments on commit a201239

Please sign in to comment.