Skip to content

Commit

Permalink
Add version info
Browse files Browse the repository at this point in the history
  • Loading branch information
denisbrodbeck committed Nov 24, 2017
1 parent 23ebc6f commit 7632cf4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cmd/sqip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// Usage: sqip [-n <int>] [-o <path>] [options...] <file>
//
// Flags:
// -n <int> number of primitive SVG shapes (default: 8)
// -o <path> save the placeholder SVG to a file (default: empty)
// -n <int> number of primitive SVG shapes (default: 8)
// -o <path> save the placeholder SVG to a file (default: empty)
// -help <bool> show this help and exit
// -version <bool> show app version and exit
// Options:
// -mode <int> shape type (default: 0)
// -alpha <int> color alpha (use 0 to let the algorithm choose alpha for each shape) (default: 128)
Expand Down Expand Up @@ -39,6 +41,7 @@ var (

func usage() {
log.Println(usageStr)
log.Println("Version:", version)
os.Exit(errorParseExitCode)
}

Expand All @@ -49,10 +52,13 @@ func failOnErr(err error) {
}
}

var version = "master" // set by ldflags

func main() {
var outFile string
var count int
var help bool
var showVersion bool
var mode int
var alpha int
var background string
Expand All @@ -61,6 +67,7 @@ func main() {
flag.IntVar(&count, "n", 8, "")
flag.BoolVar(&help, "h", false, "")
flag.BoolVar(&help, "help", false, "")
flag.BoolVar(&showVersion, "version", false, "")
flag.IntVar(&mode, "mode", 0, "")
flag.IntVar(&alpha, "alpha", 128, "")
flag.StringVar(&background, "bg", "", "")
Expand All @@ -72,6 +79,10 @@ func main() {
if help {
usage()
}
if showVersion {
log.Println(version)
os.Exit(successExitCode)
}

if flag.NArg() != 1 {
log.Println("Missing input file")
Expand Down Expand Up @@ -101,8 +112,10 @@ const usageStr = `sqip is a tool for SVG-based LQIP image creation
Usage: sqip [-n <int>] [-o <path>] [options...] <file>
Flags:
-n <int> number of primitive SVG shapes (default: 8)
-o <path> save the placeholder SVG to a file (default: empty)
-n <int> number of primitive SVG shapes (default: 8)
-o <path> save the placeholder SVG to a file (default: empty)
-help <bool> show this help and exit
-version <bool> show app version and exit
Options:
-mode <int> shape type (default: 0)
-alpha <int> color alpha (use 0 to let the algorithm choose alpha for each shape) (default: 128)
Expand Down

0 comments on commit 7632cf4

Please sign in to comment.