File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -64,15 +64,46 @@ A world of struggle.
64
64
### Steps (notes)
65
65
66
66
- create ` go-ls ` dir
67
+ - make sure the working directory is go-ls: ` cd go-ls `
67
68
- create ` go.mod ` , ` main.go ` , ` cmd/root.go `
69
+
70
+ ``` go
71
+ // go.mod
72
+ module vinery/cli-files/go -ls
73
+
74
+ go 1.18
75
+ ```
76
+
77
+ ``` go
78
+ // main.go
79
+ package main
80
+
81
+ import (
82
+ " vinery/cli-files/go-ls/cmd"
83
+ )
84
+
85
+ func main () {
86
+ cmd.Execute ()
87
+ }
88
+ ```
89
+
90
+ ``` go
91
+ // cmd/root.go
92
+ package cmd
93
+
94
+ func Execute () {}
95
+ ```
96
+
68
97
- ` go get -u github.com/spf13/cobra@latest `
69
- - follow [ user guide] ( https://github.com/spf13/cobra/blob/master/user_guide.md ) to ` main.go ` and ` root.go ` with a root command that prints hello
98
+ - follow cobra [ user guide] ( https://github.com/spf13/cobra/blob/master/user_guide.md ) to make a root command that prints hello in ` cmd/root.go `
70
99
- implement basic ls with ` os.ReadDir `
71
100
- allow the command to take arguments with ` cobra.ArbitraryArgs `
72
101
- when passed an argument such as ` go-ls assets ` , read from the passed directory
73
- - handle the error (e.g. ` Error: fdopendir go.mod: not a directory ` when passing ` go-ls ` a file argument)
102
+ - ensure that this directory path can be relative: ` go-ls .. ` and ` go-ls ../go-ls ` should both work
103
+ - handle the error (e.g. ` Error: fdopendir go.mod: not a directory ` when passing ` go-ls ` a file argument: ` go-ls go.mod ` )
74
104
- update ` go-ls ` to match ` ls ` in terms of how it handles files (hint: ` os.Stat ` )
75
105
- make ` go-ls -h ` include a helpful description
106
+ - bonus: write some tests for ` go-ls `
76
107
77
108
[ go ] : https://go.dev/
78
109
[ cat ] : https://en.m.wikipedia.org/wiki/Cat_(Unix)
You can’t perform that action at this time.
0 commit comments