Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 4bfeaef

Browse files
authored
Merge pull request #401 from joshwget/move-help-template
Move help template to main.go
2 parents 4823147 + 0126d73 commit 4bfeaef

File tree

2 files changed

+28
-37
lines changed

2 files changed

+28
-37
lines changed

cli/command/help.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

cli/main/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"os"
5+
"path"
56

67
cliApp "github.com/docker/libcompose/cli/app"
78
"github.com/docker/libcompose/cli/command"
@@ -13,6 +14,33 @@ import (
1314
func main() {
1415
factory := &dockerApp.ProjectFactory{}
1516

17+
cli.AppHelpTemplate = `Usage: {{.Name}} {{if .Flags}}[OPTIONS] {{end}}COMMAND [arg...]
18+
19+
{{.Usage}}
20+
21+
Version: {{.Version}}{{if or .Author .Email}}
22+
23+
Author:{{if .Author}}
24+
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
25+
{{.Email}}{{end}}{{end}}
26+
{{if .Flags}}
27+
Options:
28+
{{range .Flags}}{{.}}
29+
{{end}}{{end}}
30+
Commands:
31+
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
32+
{{end}}
33+
Run '{{.Name}} COMMAND --help' for more information on a command.
34+
`
35+
cli.CommandHelpTemplate = `Usage: ` + path.Base(os.Args[0]) + ` {{.Name}}{{if .Flags}} [OPTIONS]
36+
37+
{{.Usage}}
38+
39+
Options:
40+
{{range .Flags}}{{.}}
41+
{{end}}{{end}}
42+
`
43+
1644
app := cli.NewApp()
1745
app.Name = "libcompose-cli"
1846
app.Usage = "Command line interface for libcompose."

0 commit comments

Comments
 (0)