diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-09-23 23:49:29 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-09-23 23:49:29 -0700 |
commit | 8fcbf39ab97563595a726558b7e38614e68e379f (patch) | |
tree | 6e781402d3301501a9de1f382323a476217e6994 | |
parent | 26cd2bc7d628cce83188eb96534c5ed93ed48ebb (diff) |
updated usage and added cases for new
-rw-r--r-- | cmd/cms/main.go | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/cmd/cms/main.go b/cmd/cms/main.go index 8f59cb2..5550175 100644 --- a/cmd/cms/main.go +++ b/cmd/cms/main.go @@ -9,15 +9,48 @@ import ( var usage = ` $ cms <option> <params> -Options: -generate, gen, g: - Generate a new content type file with boilerplate code to implement +Options + +new <directory>: + + Creates a new 'cms' in the current directory, or one supplied + as a parameter immediately following the 'new' option. Note: 'new' + depends on the program 'git' and possibly a network connection. If there is + no local repository to clone from at the local machine's $GOPATH, 'new' will + attempt to clone the 'cms' package from over the network. + + Example: + $ cms new ~/Projects/food-reviews.dev + + + +generate, gen, g <type>: + + Generate a content type file with boilerplate code to implement the editor.Editable interface. Must be given one (1) parameter of the name of the type for the new content. Example: - $ cms gen Review + $ cms gen review + + +serve, s <service:port:tls>: + + Starts the 'cms' HTTP server for the JSON API, Admin System, or both. + Must be given at least one (1) parameter. The segments describe + which services to start, in order, either 'admin' + (Admin System / CMS backend) or 'api' (JSON API), the port to which the + service is bound, and, optionally, if the server(s) should utilize TLS + encryption (served over HTTPS), which is automatically managed using + Let's Encrypt (https://letsencrypt.org) + + Example: + $ cms serve admin:8080:tls api:8000 + (or) + $ cms serve admin:8080 + (or) + $ cms serve api:8000:tls ` func init() { @@ -30,28 +63,42 @@ func main() { flag.Parse() args := flag.Args() + if len(args) < 1 { flag.PrintDefaults() + fmt.Println("should print defaults") os.Exit(0) } - fmt.Println(args) switch args[0] { - case "generate", "gen", "g": + case "new": if len(args) < 2 { flag.PrintDefaults() os.Exit(0) } - name := args[1] + err := newProjectInDir(args[1]) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + case "generate", "gen", "g": + if len(args) < 2 { + flag.PrintDefaults() + os.Exit(0) + } - err := generateContentType(name) + err := generateContentType(args[1]) if err != nil { fmt.Println(err) os.Exit(1) } case "serve", "s": serve() + + case "": + flag.PrintDefaults() default: flag.PrintDefaults() } |