Skip to content

Commit

Permalink
adding upgrade and version to CLI usage and help command, fixing issue
Browse files Browse the repository at this point in the history
…#31 with ponzu version printing project version
  • Loading branch information
nilslice committed Jan 19, 2017
1 parent e397126 commit 4aae7bc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,17 @@ $ ponzu upgrade

### version, v

Prints the version of the Ponzu CLI you have installed.
Prints the version of Ponzu your project is using. Must be called from within a
Ponzu project directory. By passing the `--cli` flag, the `version` command will
print the version of the Ponzu CLI you have installed.

Example:
```bash
$ ponzu version
> Ponzu v0.7.1
(or)
$ ponzu --cli version
> Ponzu v0.7.2
```

---
Expand Down
15 changes: 13 additions & 2 deletions cmd/ponzu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/ponzu/ponzu.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.7.1"
"version": "0.7.2"
}
42 changes: 40 additions & 2 deletions cmd/ponzu/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4aae7bc

Please sign in to comment.