summaryrefslogtreecommitdiff
path: root/cmd/ponzu
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-01-19 09:09:44 -0800
committerSteve Manuel <nilslice@gmail.com>2017-01-19 09:09:44 -0800
commit4aae7bc1ebe1f2e51322ff8a991c7fa6f3c48168 (patch)
treeb67b531f2b9d30df2b8879010c6fe1b7594955bd /cmd/ponzu
parente397126da64633910a45631bced499943d1443a6 (diff)
adding upgrade and version to CLI usage and help command, fixing issue #31 with ponzu version printing project version
Diffstat (limited to 'cmd/ponzu')
-rw-r--r--cmd/ponzu/main.go15
-rw-r--r--cmd/ponzu/ponzu.json2
-rw-r--r--cmd/ponzu/usage.go42
3 files changed, 54 insertions, 5 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go
index 77e6708..f16e24b 100644
--- a/cmd/ponzu/main.go
+++ b/cmd/ponzu/main.go
@@ -19,11 +19,13 @@ import (
)
var (
- usage = usageHeader + usageNew + usageGenerate + usageBuild + usageRun
+ usage = usageHeader + usageNew + usageGenerate +
+ usageBuild + usageRun + usageUpgrade + usageVersion
port int
httpsport int
https bool
devhttps bool
+ cli bool
// for ponzu internal / core development
dev bool
@@ -41,6 +43,7 @@ func main() {
flag.BoolVar(&https, "https", false, "enable automatic TLS/SSL certificate management")
flag.BoolVar(&devhttps, "devhttps", false, "[dev environment] enable automatic TLS/SSL certificate management")
flag.BoolVar(&dev, "dev", false, "modify environment for Ponzu core development")
+ flag.BoolVar(&cli, "cli", false, "specify that information should be returned about the CLI, not project")
flag.StringVar(&fork, "fork", "", "modify repo source for Ponzu core development")
flag.StringVar(&gocmd, "gocmd", "go", "custom go command if using beta or new release of Go")
flag.Parse()
@@ -76,6 +79,14 @@ func main() {
case "run":
fmt.Println(usageRun)
os.Exit(0)
+
+ case "upgrade":
+ fmt.Println(usageUpgrade)
+ os.Exit(0)
+
+ case "version", "v":
+ fmt.Println(usageVersion)
+ os.Exit(0)
}
case "new":
@@ -219,7 +230,7 @@ func main() {
case "version", "v":
// read ponzu.json value to Stdout
- p, err := ponzu()
+ p, err := ponzu(cli)
if err != nil {
fmt.Println(err)
os.Exit(1)
diff --git a/cmd/ponzu/ponzu.json b/cmd/ponzu/ponzu.json
index 0e9769e..0f0b1ab 100644
--- a/cmd/ponzu/ponzu.json
+++ b/cmd/ponzu/ponzu.json
@@ -1,3 +1,3 @@
{
- "version": "0.7.1"
+ "version": "0.7.2"
} \ No newline at end of file
diff --git a/cmd/ponzu/usage.go b/cmd/ponzu/usage.go
index c53ade9..a2f6e1c 100644
--- a/cmd/ponzu/usage.go
+++ b/cmd/ponzu/usage.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "os"
"path/filepath"
"time"
)
@@ -131,10 +132,47 @@ var usageRun = `
`
-func ponzu() (map[string]interface{}, error) {
+var usageUpgrade = `
+upgrade
+
+ Will backup your own custom project code (like content, addons, uploads, etc) so
+ we can safely re-clone Ponzu from the latest version you have or from the network
+ if necessary. Before running '$ ponzu upgrade', you should update the 'ponzu'
+ package by running '$ go get -u github.com/ponzu-cms/ponzu/...'
+
+ Example:
+ $ ponzu upgrade
+
+
+`
+
+var usageVersion = `
+[--cli] version, v
+
+ Prints the version of Ponzu your project is using. Must be called from
+ within a Ponzu project directory.
+
+ Example:
+ $ ponzu version
+ > Ponzu v0.7.1
+ (or)
+ $ ponzu --cli version
+ > Ponzu v0.7.2
+
+
+`
+
+func ponzu(isCLI bool) (map[string]interface{}, error) {
kv := make(map[string]interface{})
- b, err := ioutil.ReadFile(filepath.Join("cmd", "ponzu", "ponzu.json"))
+ info := filepath.Join("cmd", "ponzu", "ponzu.json")
+ if isCLI {
+ gopath := os.Getenv("GOPATH")
+ repo := filepath.Join(gopath, "src", "github.com", "ponzu-cms", "ponzu")
+ info = filepath.Join(repo, "cmd", "ponzu", "ponzu.json")
+ }
+
+ b, err := ioutil.ReadFile(info)
if err != nil {
return nil, err
}