github.com/tcnksm/gcli@v0.2.4-0.20170129033839-7eb950507e5a/skeleton/resource/tmpl/codegangsta_cli/commands.go.tmpl (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/codegangsta/cli"
     8  	"{{ .VCSHost }}/{{ .Owner }}/{{ .Name }}/command"
     9  )
    10  
    11  var GlobalFlags = []cli.Flag{
    12  	{{ range .Flags }}cli.{{ title .TypeString }}Flag{
    13  		EnvVar: "ENV_{{ toUpper .Name }}",
    14  		Name:   "{{ .LongName }}",
    15  		{{ if eq .TypeString "string" }}Value: "{{ .Default }}", {{ end }}
    16  		Usage:  "{{ .Description }}",
    17  	},
    18  	{{ end }}
    19  }
    20  
    21  var Commands = []cli.Command{
    22  	{{ range .Commands }}{
    23  		Name:        "{{ .Name }}",
    24  		Usage:       "{{ .Synopsis }}",
    25  		Action:      command.Cmd{{ title .FunctionName }},
    26  		Flags:       []cli.Flag{},
    27  	},
    28  	{{ end }}
    29  }
    30  
    31  func CommandNotFound(c *cli.Context, command string) {
    32  	fmt.Fprintf(os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.", c.App.Name, command, c.App.Name, c.App.Name)
    33  	os.Exit(2)
    34  }