Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show our version with "-v". #56

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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