Skip to content

Commit

Permalink
Include app name & version into CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
esimov committed Mar 8, 2019
1 parent 7dd37fc commit 3164474
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"flag"
"fmt"
"go/build"
"image"
"image/draw"
Expand All @@ -21,6 +22,18 @@ import (
"github.com/google/gxui/samples/flags"
)

const HelpBanner = `
┌┬┐┬┌─┐┌─┐┬─┐┌─┐┌┬┐
│││├─┤│ ┬├┬┘├─┤│││
─┴┘┴┴ ┴└─┘┴└─┴ ┴┴ ┴
Version: %s
CLI app to convert ASCII arts into hand drawn diagrams.
`
// Version indicates the current build version.
var version string

var defaultFontFile = build.Default.GOPATH + "/src/github.com/esimov/diagram" + "/font/gloriahallelujah.ttf"

var (
Expand All @@ -33,7 +46,12 @@ var (
func main() {
rand.Seed(time.Now().UTC().UnixNano())

flag.Usage = func() {
fmt.Fprintf(os.Stderr, fmt.Sprintf(HelpBanner, version))
flag.PrintDefaults()
}
flag.Parse()

// In case the option parameters are used, the hand-drawn diagrams are generated without to enter into the CLI app.
if (*source != "") && (*destination != "") {
input := string(io.ReadFile(*source))
Expand Down

0 comments on commit 3164474

Please sign in to comment.