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
7 changes: 7 additions & 0 deletions cmd/console/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ import (
tea "github.com/charmbracelet/bubbletea"

"github.com/Ronin48/NetworkInventoryAgent/cmd/console/tui"
"github.com/Ronin48/NetworkInventoryAgent/cmd/internal/runtime"
"github.com/Ronin48/NetworkInventoryAgent/internal/sqlite"
)

func main() {
dbPath := flag.String("db", "inventory.db", "path to SQLite database file")
showVersion := flag.Bool("version", false, "print version and exit")
flag.Parse()

if *showVersion {
fmt.Fprintf(os.Stdout, "console %s\n", runtime.VersionString())
return
}

ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

Expand Down
9 changes: 5 additions & 4 deletions cmd/internal/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ import (
// of truth for both -version and any future User-Agent / metric exposition.
var Version = ""

// versionString returns a printable version. Falls back to the VCS revision
// VersionString returns a printable version. Falls back to the VCS revision
// embedded by `go build` when Version is empty, which covers the
// non-goreleaser local-build case.
func versionString() string {
// non-goreleaser local-build case. Exported so cmd/console (which doesn't
// go through Run) can produce the same -version output.
func VersionString() string {
if Version != "" {
return Version
}
Expand Down Expand Up @@ -80,7 +81,7 @@ func Run(opts Options) int {
flag.Parse()

if *showVersion {
fmt.Fprintf(os.Stdout, "%s %s\n", opts.Name, versionString())
fmt.Fprintf(os.Stdout, "%s %s\n", opts.Name, VersionString())
return 0
}

Expand Down
Loading