From 7847ab8270efab472b7b6a4bf9a57f5b83cb7212 Mon Sep 17 00:00:00 2001 From: "Joe Richey joerichey@google.com" Date: Tue, 17 Oct 2017 18:10:54 -0700 Subject: fmt almost done --- cmd/run.go | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'cmd/run.go') diff --git a/cmd/run.go b/cmd/run.go index 7765303..7517662 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -48,22 +48,46 @@ var TemplateTitle = "{{.FullName}}{{if .Command.Title}} - {{.Command.Title}}{{en var TemplateUsage = `{{with $lines := .Command.UsageLines}} Usage: {{- range $lines}} - {{$.FullName}} {{. -}} + {{printf "%s %s" $.FullName . | WrapText 8 2 -}} {{end}} {{end -}} {{with $commands := .Command.SubCommands}} +{{with $n := $.Command.MaxNameLength -}} +{{with $fmt := printf "%%-%ds - %%s" $n -}} Commands: +{{if le (add 8 $n 3 $.Command.MaxTitleLength) LineLength -}} + +{{range $commands -}} + +{{end -}} + +{{else -}} + +{{range $commands}} +{{end -}} + +{{end}}{{end}}{{end}} +{{end -}} + + {{- range $commands}} - {{.Name}}{{if .Title}} - {{.Title}}{{end -}} -{{end}} + {{if not .Title -}} + {{.Name -}} + {{else if le (add 8 $n 3 (len .Title)) LineLength -}} + {{printf $fmt .Name .Title -}} + {{else -}} + {{.Name}} + {{WrapText 16 2 .Title -}} + {{end -}} +{{end}}{{end}}{{end}} {{end -}} {{with $arguments := .FullArguments}} Arguments: {{- range $arguments}} {{.}} - {{WrapText .Usage 2 -}} + {{WrapText 16 2 .Usage -}} {{end}} {{end -}} @@ -71,7 +95,7 @@ Arguments: Options: {{- range $flags}} {{.}} - {{WrapText .FullUsage 2 -}} + {{WrapText 16 2 .FullUsage -}} {{end}} {{end -}} -- cgit v1.3