|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "os" |
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/localstack/lstk/internal/api" |
9 | 10 | "github.com/localstack/lstk/internal/config" |
@@ -38,6 +39,33 @@ var rootCmd = &cobra.Command{ |
38 | 39 | func init() { |
39 | 40 | rootCmd.Version = version.Version() |
40 | 41 | rootCmd.SetVersionTemplate(versionLine() + "\n") |
| 42 | + |
| 43 | + rootCmd.InitDefaultHelpFlag() |
| 44 | + rootCmd.Flags().Lookup("help").Usage = "Show help" |
| 45 | + |
| 46 | + rootCmd.InitDefaultVersionFlag() |
| 47 | + rootCmd.Flags().Lookup("version").Usage = "Show version" |
| 48 | + |
| 49 | + usageTemplate := rootCmd.UsageTemplate() |
| 50 | + usageTemplate = strings.Replace(usageTemplate, "Available Commands:", "Commands:", 1) |
| 51 | + usageTemplate = strings.Replace(usageTemplate, "Flags:", "Options:", 1) |
| 52 | + usageTemplate = strings.Replace( |
| 53 | + usageTemplate, |
| 54 | + `Usage:{{if .Runnable}} |
| 55 | + {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} |
| 56 | + {{.CommandPath}} [command]{{end}}`, |
| 57 | + `Usage: {{if eq .CommandPath "lstk"}}lstk [options] [command]{{else}}{{.UseLine}}{{end}}{{if eq .CommandPath "lstk"}} |
| 58 | +
|
| 59 | +LSTK - LocalStack command-line interace{{end}}`, |
| 60 | + 1, |
| 61 | + ) |
| 62 | + usageTemplate = strings.ReplaceAll(usageTemplate, `Use "{{.CommandPath}} [command] --help" for more information about a command.`, "") |
| 63 | + usageTemplate = strings.TrimRight(usageTemplate, "\n") |
| 64 | + rootCmd.SetUsageTemplate(usageTemplate) |
| 65 | + |
| 66 | + rootCmd.SetHelpTemplate(`{{if eq .CommandPath "lstk"}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}{{else}}{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}} |
| 67 | +
|
| 68 | +{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}{{end}}`) |
41 | 69 | rootCmd.AddCommand(startCmd) |
42 | 70 | } |
43 | 71 |
|
|
0 commit comments