forked from toolshed/abra
		
	
							
								
								
									
										31
									
								
								cli/run.go
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								cli/run.go
									
									
									
									
									
								
							@ -19,6 +19,35 @@ import (
 | 
			
		||||
	"github.com/spf13/cobra/doc"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// translators: `abra` usage template. please translate only words like
 | 
			
		||||
	// "Aliases" and "Example" and nothing inside the {{ ... }}
 | 
			
		||||
	usageTemplate = i18n.G(`Usage:{{if .Runnable}}
 | 
			
		||||
  {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
  {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
 | 
			
		||||
 | 
			
		||||
Aliases:
 | 
			
		||||
  {{.NameAndAliases}}{{end}}{{if .HasExample}}
 | 
			
		||||
 | 
			
		||||
Examples:
 | 
			
		||||
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
 | 
			
		||||
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
 | 
			
		||||
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
 | 
			
		||||
 | 
			
		||||
Flags:
 | 
			
		||||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
 | 
			
		||||
 | 
			
		||||
Global Flags:
 | 
			
		||||
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
 | 
			
		||||
 | 
			
		||||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
 | 
			
		||||
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
 | 
			
		||||
 | 
			
		||||
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
 | 
			
		||||
`)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Run(version, commit string) {
 | 
			
		||||
	rootCmd := &cobra.Command{
 | 
			
		||||
		// translators: `abra` binary name
 | 
			
		||||
@ -35,7 +64,6 @@ func Run(version, commit string) {
 | 
			
		||||
			i18n.G("server"),
 | 
			
		||||
			i18n.G("upgrade"),
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
 | 
			
		||||
			dirs := []map[string]os.FileMode{
 | 
			
		||||
				{config.ABRA_DIR: 0764},
 | 
			
		||||
@ -78,6 +106,7 @@ func Run(version, commit string) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rootCmd.CompletionOptions.DisableDefaultCmd = true
 | 
			
		||||
	rootCmd.SetUsageTemplate(usageTemplate)
 | 
			
		||||
 | 
			
		||||
	manCommand := &cobra.Command{
 | 
			
		||||
		// translators: `man` command
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user