Skip to content

Commit

Permalink
version sub command
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft committed Feb 14, 2019
1 parent ebdc644 commit 5167bee
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion spiff++.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
func main() {
app := cli.NewApp()
app.Name = "spiff"
app.Usage = "BOSH deployment manifest toolkit"
app.Usage = "YAML in-domain templating processor"
app.Version = "1.3.0-dev"

app.Commands = []cli.Command{
Expand Down Expand Up @@ -81,6 +81,28 @@ func main() {
diff(c.Args()[0], c.Args()[1], c.String("separator"))
},
},
{
Name: "version",
Usage: "show verson info",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "q",
Usage: "print version only",
},
},
Action: func(c *cli.Context) {
if len(c.Args()) > 0 {
cli.ShowCommandHelp(c, "version")
os.Exit(1)
}

if c.Bool("q") {
fmt.Printf("%s\n", app.Version)
} else {
fmt.Printf("%s version %s\n", app.Name, app.Version)
}
},
},
}

app.Run(os.Args)
Expand Down

0 comments on commit 5167bee

Please sign in to comment.