Add -v/--version flag to print version string (#3883)

* Add `-v/--version` flag to print version string

- Created a new flag `-v/--version` in the command-line interface to display the version number and exit.
- Moved all version-related functions inside the config package to the new file `manager/config/version.go` to avoid circular dependencies.
- Added a new `GetVersionString()` function to generate a formatted version string.
- Updated references to the moved version functions.
- Updated references in the `Makefile`.

* Move version embeds to build package

* Remove githash var

---------

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Csaba Maulis
2023-07-11 13:54:42 +08:00
committed by GitHub
parent 969af2ab69
commit 0c0ba19a23
8 changed files with 79 additions and 64 deletions

View File

@@ -7,6 +7,7 @@ import (
"sort"
"strconv"
"github.com/stashapp/stash/internal/build"
"github.com/stashapp/stash/internal/manager"
"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/models"
@@ -188,7 +189,7 @@ func (r *queryResolver) Stats(ctx context.Context) (*StatsResultType, error) {
}
func (r *queryResolver) Version(ctx context.Context) (*Version, error) {
version, hash, buildtime := GetVersion()
version, hash, buildtime := build.Version()
return &Version{
Version: &version,