Skip to content

Commit

Permalink
Add usage output and cross-compile build cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed May 26, 2018
1 parent a5f6723 commit 5c6e72c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 16 additions & 0 deletions fnbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eux

MOON="fndec"
DIR="release"
mkdir "$DIR"
env GOOS=windows GOARCH=386 go build
mv "$MOON".exe "${DIR}/${MOON}"-win386.exe
env GOOS=windows GOARCH=amd64 go build
mv "$MOON".exe "${DIR}/${MOON}"-win64.exe
env GOOS=linux GOARCH=amd64 go build
mv "$MOON" "${DIR}/${MOON}"-linux64
env GOOS=darwin GOARCH=386 go build
mv "$MOON" "${DIR}/${MOON}"-darwin386
env GOOS=darwin GOARCH=amd64 go build
mv "$MOON" "${DIR}/${MOON}"-darwinAmd64
18 changes: 17 additions & 1 deletion fndec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import (
"path/filepath"
)

const version = "fndec-0.0.2"

var (
file string
vers bool
)

func init() {
flag.StringVar(&file, "file", "false", "File to read the fname from.")
flag.StringVar(&file, "file", "false", "File to read the filename from.")
flag.BoolVar(&vers, "version", false, "Return version information.")
}

func readFileName(path string, fi os.FileInfo, err error) error {
Expand All @@ -24,5 +28,17 @@ func readFileName(path string, fi os.FileInfo, err error) error {

func main() {
flag.Parse()
if vers {
fmt.Fprintf(os.Stderr, "%s\n", version)
os.Exit(0)
} else if flag.NFlag() < 1 {
fmt.Fprintln(os.Stderr, "Usage: fndec [-file ...]")
fmt.Fprintln(os.Stderr, " [Optional: -version]")
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "Output: Character encoding for fname: {fname} detected: {encoding}")
fmt.Fprintf(os.Stderr, "Output: [String] '%s ...'\n\n", version)
flag.Usage()
os.Exit(0)
}
filepath.Walk(file, readFileName)
}

0 comments on commit 5c6e72c

Please sign in to comment.