summaryrefslogtreecommitdiff
path: root/cmd/ponzu/main.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-06-10 17:09:47 -0600
committerGitHub <noreply@github.com>2017-06-10 17:09:47 -0600
commite3fb3aba33645ef1c7ba1d1556c806d7c0eb853b (patch)
treee65b5a0dc7579b0af904c487570c5c5ade742f7b /cmd/ponzu/main.go
parent427dff52c3db481dff38dd1eee83f93e54ea8065 (diff)
parent4d767c13f15b24fdbfcb610589e757a98c931d70 (diff)
Merge pull request #159 from ponzu-cms/ponzu-dev
[cli] adding documentation server for local use
Diffstat (limited to 'cmd/ponzu/main.go')
-rw-r--r--cmd/ponzu/main.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go
index 7572dcc..25e1694 100644
--- a/cmd/ponzu/main.go
+++ b/cmd/ponzu/main.go
@@ -26,17 +26,20 @@ import (
)
var (
- port int
httpsport int
+ port int
+ docsport int
https bool
devhttps bool
+ docs bool
cli bool
// for ponzu internal / core development
- dev bool
- fork string
gocmd string
- year = fmt.Sprintf("%d", time.Now().Year())
+ fork string
+ dev bool
+
+ year = fmt.Sprintf("%d", time.Now().Year())
)
var rootCmd = &cobra.Command{
@@ -55,7 +58,7 @@ The segments, separated by a comma, describe which services to start, either
if the server should utilize TLS encryption - served over HTTPS, which is
automatically managed using Let's Encrypt (https://letsencrypt.org)
-Defaults to 'run -port=8080 admin,api' (running Admin & API on port 8080, without TLS)
+Defaults to 'run --port=8080 admin,api' (running Admin & API on port 8080, without TLS)
Note:
Admin and API cannot run on separate processes unless you use a copy of the
@@ -81,6 +84,13 @@ $ ponzu run --port=8888 api`,
addTLS = "--dev-https"
}
+ var addDocs string
+ if docs {
+ addDocs = "--docs"
+ } else {
+ addDocs = "--docs=false"
+ }
+
var services string
if len(args) > 0 {
services = args[0]
@@ -95,6 +105,8 @@ $ ponzu run --port=8888 api`,
services,
fmt.Sprintf("--port=%d", port),
fmt.Sprintf("--https-port=%d", httpsport),
+ fmt.Sprintf("--docs-port=%d", docsport),
+ addDocs,
addTLS,
)
serve.Stderr = os.Stderr
@@ -137,6 +149,11 @@ var serveCmd = &cobra.Command{
}
}
+ // run docs server if --docs is true
+ if docs {
+ admin.Docs(docsport)
+ }
+
// save the https port the system is listening on
err := db.PutConfig("https_port", fmt.Sprintf("%d", httpsport))
if err != nil {
@@ -176,14 +193,16 @@ var serveCmd = &cobra.Command{
func init() {
for _, cmd := range []*cobra.Command{runCmd, serveCmd} {
- cmd.Flags().IntVar(&port, "port", 8080, "port for ponzu to bind its HTTP listener")
cmd.Flags().IntVar(&httpsport, "https-port", 443, "port for ponzu to bind its HTTPS listener")
+ cmd.Flags().IntVar(&port, "port", 8080, "port for ponzu to bind its HTTP listener")
+ cmd.Flags().IntVar(&docsport, "docs-port", 1234, "[dev environment] override the documentation server port")
+ cmd.Flags().BoolVar(&docs, "docs", false, "[dev environment] run HTTP server to view local HTML documentation")
cmd.Flags().BoolVar(&https, "https", false, "enable automatic TLS/SSL certificate management")
cmd.Flags().BoolVar(&devhttps, "dev-https", false, "[dev environment] enable automatic TLS/SSL certificate management")
}
- RegisterCmdlineCommand(runCmd)
RegisterCmdlineCommand(serveCmd)
+ RegisterCmdlineCommand(runCmd)
pflags := rootCmd.PersistentFlags()
pflags.StringVar(&gocmd, "gocmd", "go", "custom go command if using beta or new release of Go")