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