Skip to content
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
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_darwin_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_darwin_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_js_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_linux_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_linux_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_windows_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
3 changes: 1 addition & 2 deletions pkg/gen/gljimports/gljimports_windows_arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.NewEnvironment", github_com_glojurelang_glojure_pkg_runtime.NewEnvironment)
_register("github.com/glojurelang/glojure/pkg/runtime.NewFn", github_com_glojurelang_glojure_pkg_runtime.NewFn)
_register("github.com/glojurelang/glojure/pkg/runtime.NewGenerator", github_com_glojurelang_glojure_pkg_runtime.NewGenerator)
_register("github.com/glojurelang/glojure/pkg/runtime.ParseVersion", github_com_glojurelang_glojure_pkg_runtime.ParseVersion)
_register("github.com/glojurelang/glojure/pkg/runtime.RT", github_com_glojurelang_glojure_pkg_runtime.RT)
_register("github.com/glojurelang/glojure/pkg/runtime.RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)).Elem())
_register("github.com/glojurelang/glojure/pkg/runtime.*RTEvalError", reflect.TypeOf((*github_com_glojurelang_glojure_pkg_runtime.RTEvalError)(nil)))
Expand All @@ -4022,7 +4021,7 @@ func RegisterImports(_register func(string, interface{})) {
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolSpliceUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolSpliceUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUnquote", github_com_glojurelang_glojure_pkg_runtime.SymbolUnquote)
_register("github.com/glojurelang/glojure/pkg/runtime.SymbolUserNamespace", github_com_glojurelang_glojure_pkg_runtime.SymbolUserNamespace)
_register("github.com/glojurelang/glojure/pkg/runtime.VERSION", github_com_glojurelang_glojure_pkg_runtime.VERSION)
_register("github.com/glojurelang/glojure/pkg/runtime.Version", github_com_glojurelang_glojure_pkg_runtime.Version)
_register("github.com/glojurelang/glojure/pkg/runtime.WithEnv", github_com_glojurelang_glojure_pkg_runtime.WithEnv)
_register("github.com/glojurelang/glojure/pkg/runtime.WithFilename", github_com_glojurelang_glojure_pkg_runtime.WithFilename)
_register("github.com/glojurelang/glojure/pkg/runtime.WithLoadPath", github_com_glojurelang_glojure_pkg_runtime.WithLoadPath)
Expand Down
4 changes: 2 additions & 2 deletions pkg/gljmain/gljmain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Examples:
glj --help # Show this help

For more information, visit: https://github.com/glojurelang/glojure
`, runtime.VERSION)
`, runtime.Version)
}

func Main(args []string) {
Expand All @@ -43,7 +43,7 @@ func Main(args []string) {
if len(args) == 0 {
repl.Start()
} else if args[0] == "--version" {
fmt.Printf("glojure v%s\n", runtime.VERSION)
fmt.Printf("glojure v%s\n", runtime.Version)
return
} else if args[0] == "--help" || args[0] == "-h" {
printHelp()
Expand Down
27 changes: 20 additions & 7 deletions pkg/runtime/envinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@ import (
"fmt"
"io"
"os"
"runtime/debug"
"strconv"
"strings"

"github.com/glojurelang/glojure/pkg/lang"
)

// The current version of Glojure
const VERSION = "0.3.0"
var (
// The current version of Glojure
Version = func() string {
info, ok := debug.ReadBuildInfo()
if !ok {
return "0.0.0"
}
if info.Main.Version == "" || info.Main.Version == "(devel)" {
return "0.0.0"
}
// Trim any leading "v" from the version string
return strings.TrimPrefix(info.Main.Version, "v")
}()
)

// ParseVersion parses the VERSION string and returns a map with major, minor,
// parseVersion parses the Version string and returns a map with major, minor,
// incremental, and qualifier
func ParseVersion(version string) lang.IPersistentMap {
func parseVersion(version string) lang.IPersistentMap {
parts := strings.Split(version, ".")

major, _ := strconv.Atoi(parts[0])
minor, _ := strconv.Atoi(parts[1])

incremental := 0
qualifier := interface{}(nil)
var qualifier any

if len(parts) > 2 {
// Check if the third part contains a qualifier (e.g., "0-alpha")
incrementalPart := parts[2]
incrementalPart := strings.Join(parts[2:], ".")
if strings.Contains(incrementalPart, "-") {
qualifierParts := strings.SplitN(incrementalPart, "-", 2)
incremental, _ = strconv.Atoi(qualifierParts[0])
Expand Down Expand Up @@ -129,7 +142,7 @@ func NewEnvironment(opts ...EvalOption) lang.Environment {
core := lang.FindNamespace(lang.NewSymbol("clojure.core"))
versionVar := core.FindInternedVar(lang.NewSymbol("*glojure-version*"))
if versionVar != nil {
versionVar.BindRoot(ParseVersion(VERSION))
versionVar.BindRoot(parseVersion(Version))
}

lang.InternVar(core, lang.NewSymbol("load-file"), func(filename string) any {
Expand Down
2 changes: 1 addition & 1 deletion pkg/stdlib/clojure/core/loader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions test/glojure/test_glojure/cli.glj
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,12 @@
(test-that
"glj --help flag works correctly"
(let [[out err] (run-cli-cmd glj "--help")]
(is (re-matches
#"(?s).*Glojure v0\.3\.0.*Usage: glj.*Options:.*-e.*-h.*--help.*--version.*Examples:.*"
out)
"Command should output help information")
(is (empty? err) "Command should not return an error"))))

(deftest short-help-flag-test
(test-that
"glj -h flag works correctly"
(let [[out err] (run-cli-cmd glj "-h")]
(is (re-matches
#"(?s).*Glojure v0\.3\.0.*Usage: glj.*Options:.*-e.*-h.*--help.*--version.*Examples:.*"
out)
"Command should output help information")
(is (empty? err) "Command should not return an error"))))

(run-tests)