Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Nov 1, 2017
1 parent 645d66d commit 8b77fe8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
22 changes: 18 additions & 4 deletions .goreleaser.yml
Expand Up @@ -5,18 +5,30 @@ build:
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
- freebsd
- netbsd
- openbsd
- dragonfly
goarch:
- amd64
- 386
- arm
- arm64
ignore:
- goos: openbsd
goarch: arm
goarm: 6

fpm:
formats:
- deb
vendor: "gohugo.io"
homepage: "https://gohugo.io/"
maintainer: "Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>"
description: "A Fast and Flexible Static Site Generator built with love in GoLang."
vendor: "Baldanders.info"
homepage: "http://www.baldanders.info/"
maintainer: "Spiegel <spiegel-im-spiegel@gmail.com>"
description: "relrease demo"
license: "Apache 2.0"
archive:
format: tar.gz
Expand All @@ -39,3 +51,5 @@ archive:
files:
- README.md
- LICENSE
release:
draft: false
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -9,3 +9,6 @@ install:
script:
- $GOPATH/bin/dep ensure -v
- go test -v ./...

after_success:
- test -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash
10 changes: 8 additions & 2 deletions cli/reldemo/facade/facade.go
Expand Up @@ -13,7 +13,7 @@ const (
//Name is applicatin name
Name = "godump"
//Version is version for applicatin
Version = "v0.1.1"
Version = "v0.0.x"
)

//ExitCode is OS exit code enumeration class
Expand Down Expand Up @@ -44,13 +44,18 @@ func (c ExitCode) String() string {
}

var (
cui = gocli.NewUI()
cui = gocli.NewUI()
versionFlag = false
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: Name + " [flags] [binary file]",
RunE: func(cmd *cobra.Command, args []string) error {
if versionFlag {
cui.Outputln(Name, Version)
return nil
}
name, err := cmd.Flags().GetString("name")
if err != nil {
return err
Expand Down Expand Up @@ -101,5 +106,6 @@ func Execute(ui *gocli.UI) (exit ExitCode) {
}

func init() {
rootCmd.Flags().BoolVarP(&versionFlag, "vaersion", "v", false, "output version")
rootCmd.Flags().StringP("name", "n", "dumpList", "value name")
}

0 comments on commit 8b77fe8

Please sign in to comment.