Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 7f85e04

Browse files
authored
Merge pull request #341 from lclarkmichalek/doc-examples
Add examples to the main usage output
2 parents 4105d3a + 2f9ea21 commit 7f85e04

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cmd/dep/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,28 @@ func main() {
4040
&hashinCommand{},
4141
}
4242

43+
examples := [][2]string{
44+
{
45+
"dep init",
46+
"set up a new project",
47+
},
48+
{
49+
"dep ensure",
50+
"install the project's dependencies",
51+
},
52+
{
53+
"dep ensure -update",
54+
"update the locked versions of all dependencies",
55+
},
56+
{
57+
"dep ensure github.com/pkg/errors",
58+
"add a dependency to the project",
59+
},
60+
}
61+
4362
usage := func() {
63+
fmt.Fprintln(os.Stderr, "dep is a tool for managing dependencies for Go projects")
64+
fmt.Fprintln(os.Stderr)
4465
fmt.Fprintln(os.Stderr, "Usage: dep <command>")
4566
fmt.Fprintln(os.Stderr)
4667
fmt.Fprintln(os.Stderr, "Commands:")
@@ -53,6 +74,12 @@ func main() {
5374
}
5475
w.Flush()
5576
fmt.Fprintln(os.Stderr)
77+
fmt.Fprintln(os.Stderr, "Examples:")
78+
for _, example := range examples {
79+
fmt.Fprintf(w, "\t%s\t%s\n", example[0], example[1])
80+
}
81+
w.Flush()
82+
fmt.Fprintln(os.Stderr)
5683
fmt.Fprintln(os.Stderr, "Use \"dep help [command]\" for more information about a command.")
5784
}
5885

0 commit comments

Comments
 (0)