Skip to content

Commit

Permalink
Add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Jan 1, 2018
1 parent a4c05a4 commit 848026e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import (
"github.com/skratchdot/open-golang/open"
)

const Usage = "Usage: whichpr show|open SHA1"
const Usage = `Usage:
whichpr show|open SHA1
whichpr version
`

var version = "master"

type ErrorMessage struct {
message string
Expand Down Expand Up @@ -54,21 +59,35 @@ func main() {
}

func Main(args []string) error {
if len(args) != 3 {
if len(args) < 2 {
return NewErrorMessage("")
}
command := args[1]
sha1 := args[2]
switch command {
case "show":
if len(args) != 3 {
return NewErrorMessage("")
}
sha1 := args[2]
return Show(sha1)
case "open":
if len(args) != 3 {
return NewErrorMessage("")
}
sha1 := args[2]
return Open(sha1)
case "version":
return Version()
default:
return NewErrorMessage(fmt.Sprintf("%s is unknown command", command))
}
}

func Version() error {
fmt.Println(version)
return nil
}

func Show(sha1 string) error {
prj, err := Project()
if err != nil {
Expand Down

0 comments on commit 848026e

Please sign in to comment.