Skip to content

Commit 740abac

Browse files
committed
redo file structure for commands and add gitignores
1 parent d6ad4cd commit 740abac

File tree

12 files changed

+83
-6
lines changed

12 files changed

+83
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!*/assets

Go.AllowList.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
4+
# Allowlisting gitignore template for GO projects prevents us
5+
# from adding various unwanted local files, such as generated
6+
# files, developer configurations or IDE-specific files etc.
7+
#
8+
# Recommended: Go.AllowList.gitignore
9+
10+
# Ignore everything
11+
*
12+
13+
# But not these files...
14+
!/.gitignore
15+
16+
!*.go
17+
!go.sum
18+
!go.mod
19+
20+
!README.md
21+
!LICENSE
22+
23+
# !Makefile
24+
25+
# ...even if they are in subdirectories
26+
!*/

cli-files/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ And within every dewdrop
6161
A world of struggle.
6262
```
6363

64+
### Steps (notes)
65+
66+
- Setup cobra with https://github.com/spf13/cobra/blob/master/user_guide.md
67+
- install in cli-files `go get -u github.com/spf13/cobra@latest`
68+
- `cmd` directory, `root.go`
69+
6470
[go]: https://go.dev/
6571
[cat]: https://en.m.wikipedia.org/wiki/Cat_(Unix)
6672
[ls]: https://en.m.wikipedia.org/wiki/Ls
File renamed without changes.
File renamed without changes.
File renamed without changes.

cli-files/go-ls/cmd/root.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var rootCmd = &cobra.Command{
11+
Use: "go-ls",
12+
Short: "go-ls is a re-implementation of the ls command",
13+
Run: func(cmd *cobra.Command, args []string) {},
14+
}
15+
16+
func Execute() {
17+
if err := rootCmd.Execute(); err != nil {
18+
fmt.Fprintln(os.Stderr, err)
19+
os.Exit(1)
20+
}
21+
}

cli-files/go-ls/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module vinery/cli-files/go-ls
2+
3+
go 1.18
4+
5+
require github.com/spf13/cobra v1.4.0
6+
7+
require (
8+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
9+
github.com/spf13/pflag v1.0.5 // indirect
10+
)

cli-files/go-ls/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
3+
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
4+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
5+
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
6+
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
7+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
8+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

cli-files/go-ls/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
3+
import (
4+
"vinery/cli-files/go-ls/cmd"
5+
)
6+
7+
func main() {
8+
cmd.Execute()
9+
}

0 commit comments

Comments
 (0)