main.go

 1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5// Package main is the entry point for the lune CLI.
 6package main
 7
 8import (
 9	"context"
10	"os"
11	"runtime/debug"
12
13	"git.secluded.site/lune/cmd"
14)
15
16// version is set at build time via ldflags for release builds.
17// For go install, we read from debug.ReadBuildInfo() instead.
18var version = "dev"
19
20func main() {
21	if err := cmd.Execute(context.Background(), resolveVersion()); err != nil {
22		os.Exit(1)
23	}
24}
25
26// resolveVersion returns the version from build info (go install) if available,
27// otherwise falls back to the ldflags-injected version (release builds).
28func resolveVersion() string {
29	info, ok := debug.ReadBuildInfo()
30	if ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
31		return info.Main.Version
32	}
33
34	return version
35}