summaryrefslogtreecommitdiff
path: root/cmd/ponzu/main.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-01-17 16:31:38 -0800
committerSteve Manuel <nilslice@gmail.com>2017-01-17 16:31:38 -0800
commit36bd970589e92c09709aa778f9ff02d16fde7e08 (patch)
tree87d113ddec8dd7310134115edc2794b7f69e1fcc /cmd/ponzu/main.go
parent3c5a7f8020eeebb50a94c0c997dfd7404b1afabc (diff)
adding version (in general ponzu.json file) and upgrade command to backup, clone new ponzu and restore files to keep up to date as ponzu project is updated
Diffstat (limited to 'cmd/ponzu/main.go')
-rw-r--r--cmd/ponzu/main.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go
index e90d318..77e6708 100644
--- a/cmd/ponzu/main.go
+++ b/cmd/ponzu/main.go
@@ -216,6 +216,49 @@ func main() {
fmt.Println("\nvisit `/admin` to get started.")
log.Fatalln(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
+ case "version", "v":
+ // read ponzu.json value to Stdout
+
+ p, err := ponzu()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ fmt.Fprintf(os.Stdout, "Ponzu v%s\n", p["version"])
+
+ case "upgrade":
+ // confirm since upgrade will replace Ponzu core files
+ path, err := os.Getwd()
+ if err != nil {
+ fmt.Println("Failed to find current directory.", err)
+ os.Exit(1)
+ }
+
+ fmt.Println("Only files you added to this directory, 'addons' and 'content' will be preserved.")
+ fmt.Println("Upgrade this project? (y/N):")
+
+ answer, err := getAnswer()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ switch answer {
+ case "n", "no", "\r\n", "\n", "":
+ fmt.Println("")
+
+ case "y", "yes":
+ err := upgradePonzuProjectDir(path)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ default:
+ fmt.Println("Input not recognized. No upgrade made. Answer as 'y' or 'n' only.")
+ }
+
case "":
fmt.Println(usage)
fmt.Println(usageHelp)