Skip to content

Commit 1ba345c

Browse files
committed
redo file structure for commands and add gitignores
1 parent 93a6964 commit 1ba345c

File tree

7 files changed

+85
-0
lines changed

7 files changed

+85
-0
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ And within every dewdrop
6161
A world of struggle.
6262
```
6363

64+
<<<<<<< HEAD
6465
### go-ls
6566

6667
These steps will leave some work for you to do. If something's not clear, search around for to find the answer. If you're stuck for half an hour at most, ask for help. Remember to use Git to store your progress, committing often in small increments with useful descriptions.
@@ -165,6 +166,13 @@ Let's try it out: `go install . && go-cat`. It will do nothing, but it's a start
165166
Now it's over to you: set up a command that takes a path to a file as an argument, then opens that file and prints it out. You'll need the built-in go functions `os.ReadFile` and `os.Stdout.Write`, as well as more from the `os` package.
166167

167168
Bonus task: handle the error if you pass it a directory rather than a file, like cat does.
169+
=======
170+
### Steps (notes)
171+
172+
- Setup cobra with https://github.com/spf13/cobra/blob/master/user_guide.md
173+
- install in cli-files `go get -u github.com/spf13/cobra@latest`
174+
- `cmd` directory, `root.go`
175+
>>>>>>> 740abac (redo file structure for commands and add gitignores)
168176
169177
[go]: https://go.dev/
170178
[cat]: https://en.m.wikipedia.org/wiki/Cat_(Unix)

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)