github.com/goonzoid/gcli@v0.2.3-0.20150926213610-155587606ea1/skeleton/framework.go (about) 1 package skeleton 2 3 import "fmt" 4 5 // Framework represents framework 6 type Framework struct { 7 // Name is framework name 8 Name string 9 10 // AltName is alternative name which represent Framework 11 AltNames []string 12 13 // Description is description of framework 14 Description string 15 16 // URL is framework project URL 17 URL string 18 19 // BaseTemplates 20 BaseTemplates []Template 21 22 // CommandTemplate 23 CommandTemplates []Template 24 25 // If Hide is true, `list` command doesn't show 26 // this framework 27 Hide bool 28 } 29 30 // CommonTemplates is collection of templates which are used all frameworks. 31 var CommonTemplates = []Template{ 32 {"resource/tmpl/common/CHANGELOG.md.tmpl", "CHANGELOG.md"}, 33 {"resource/tmpl/common/README.md.tmpl", "README.md"}, 34 } 35 36 // Frameworks is collection of Framework. 37 var Frameworks = []*Framework{ 38 { 39 Name: "mitchellh_cli", 40 AltNames: []string{"mitchellh"}, 41 URL: "https://github.com/mitchellh/cli", 42 Description: `mitchellh/cli cli is a library for implementing powerful command-line interfaces in Go. 43 cli is the library that powers the CLI for Packer, Serf, and Consul. 44 `, 45 BaseTemplates: []Template{ 46 {"resource/tmpl/mitchellh_cli/main.go.tmpl", "main.go"}, 47 {"resource/tmpl/mitchellh_cli/version.go.tmpl", "version.go"}, 48 {"resource/tmpl/mitchellh_cli/cli.go.tmpl", "cli.go"}, 49 {"resource/tmpl/mitchellh_cli/commands.go.tmpl", "commands.go"}, 50 {"resource/tmpl/mitchellh_cli/command/meta.go.tmpl", "command/meta.go"}, 51 {"resource/tmpl/mitchellh_cli/command/version.go.tmpl", "command/version.go"}, 52 }, 53 CommandTemplates: []Template{ 54 {"resource/tmpl/mitchellh_cli/command/command.go.tmpl", "command/{{ .Name }}.go"}, 55 {"resource/tmpl/mitchellh_cli/command/command_test.go.tmpl", "command/{{ .Name }}_test.go"}, 56 }, 57 }, 58 59 { 60 Name: "codegangsta_cli", 61 AltNames: []string{"codegangsta"}, 62 URL: "https://github.com/codegangsta/cli", 63 Description: `codegangsta/cli is simple, fast, and fun package for building command line apps in Go. 64 The goal is to enable developers to write fast and distributable command line applications in an expressive way. 65 `, 66 BaseTemplates: []Template{ 67 {"resource/tmpl/codegangsta_cli/main.go.tmpl", "main.go"}, 68 {"resource/tmpl/codegangsta_cli/version.go.tmpl", "version.go"}, 69 {"resource/tmpl/codegangsta_cli/commands.go.tmpl", "commands.go"}, 70 }, 71 CommandTemplates: []Template{ 72 {"resource/tmpl/codegangsta_cli/command/command.go.tmpl", "command/{{ .Name }}.go"}, 73 {"resource/tmpl/codegangsta_cli/command/command_test.go.tmpl", "command/{{ .Name }}_test.go"}, 74 }, 75 }, 76 77 { 78 Name: "go_cmd", 79 URL: "https://github.com/golang/go/tree/master/src/cmd/go", 80 Description: ` 81 `, 82 BaseTemplates: []Template{ 83 {"resource/tmpl/go_cmd/main.go.tmpl", "main.go"}, 84 }, 85 CommandTemplates: []Template{ 86 {"resource/tmpl/go_cmd/command.go.tmpl", "{{ .Name }}.go"}, 87 {"resource/tmpl/go_cmd/command_test.go.tmpl", "{{ .Name }}_test.go"}, 88 }, 89 }, 90 91 { 92 Name: "bash", 93 URL: "", 94 Description: ` 95 `, 96 BaseTemplates: []Template{ 97 {"resource/tmpl/bash/main.sh.tmpl", "{{ .Name }}.sh"}, 98 }, 99 CommandTemplates: []Template{}, 100 Hide: true, 101 }, 102 103 { 104 Name: "flag", 105 AltNames: []string{}, 106 URL: "https://golang.org/pkg/flag/", 107 Description: `Package flag implements command-line flag parsing.`, 108 BaseTemplates: []Template{ 109 {"resource/tmpl/flag/main.go.tmpl", "main.go"}, 110 {"resource/tmpl/flag/version.go.tmpl", "version.go"}, 111 {"resource/tmpl/flag/cli.go.tmpl", "cli.go"}, 112 {"resource/tmpl/flag/cli_test.go.tmpl", "cli_test.go"}, 113 }, 114 CommandTemplates: []Template{}, 115 }, 116 } 117 118 // FrameworkByName retuns Framework 119 func FrameworkByName(name string) (*Framework, error) { 120 for _, f := range Frameworks { 121 if f.Name == name { 122 return f, nil 123 } 124 125 for _, alt := range f.AltNames { 126 if alt == name { 127 return f, nil 128 } 129 } 130 } 131 return nil, fmt.Errorf("invalid framework name: %s", name) 132 }