Skip to content

Commit

Permalink
Merge pull request #56 from skx/51-version
Browse files Browse the repository at this point in the history
Show our version with "-v".
  • Loading branch information
skx authored Oct 17, 2022
2 parents 988850a + cecf186 commit 1290c5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/build
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for OS in ${BUILD_PLATFORMS[@]}; do
export CGO_ENABLED=0

# Build the main-binary
go build -ldflags "-X main.version=$(git describe --tags 2>/dev/null || echo 'master')" -o "${BASE}-${SUFFIX}"
go build -ldflags "-X main.version=$(git describe --tags 2>/dev/null || echo 'master') -X main.sha1sum=$(git rev-parse HEAD)" -o "${BASE}-${SUFFIX}"

done
done
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
"github.com/skx/yal/stdlib"
)

var (
version = "unreleased"
sha1sum = "unknown"
)

func main() {

// (gensym) needs a decent random seed, as does (random).
Expand All @@ -32,8 +37,15 @@ func main() {
// Look to see if we're gonna execute a statement, or dump our help.
exp := flag.String("e", "", "A string to evaluate.")
hlp := flag.Bool("h", false, "Should we show help information, and exit?")
ver := flag.Bool("v", false, "Should we show our version, and exit?")
flag.Parse()

// Showing the version?
if *ver {
fmt.Printf("%s [%s]\n", version, sha1sum)
return
}

// Ensure we have an argument, if we don't have flags.
if len(flag.Args()) < 1 && (*exp == "") && !*hlp {
fmt.Printf("Usage: yal [-e expr] [-h] file.lisp\n")
Expand Down

0 comments on commit 1290c5b

Please sign in to comment.