Add version flag to display current version
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -13,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type CLI struct {
|
||||
Version kong.VersionFlag `short:"v"`
|
||||
NoConfigFile bool `short:"C" default:"false" help:"Disable config file creation."`
|
||||
ConfigFilePath string `short:"c" default:"bibliomane.toml" type:"path" help:"Config file path."`
|
||||
DisableStoreJWTKeyInConfig bool `default:"false" help:"Do not store the generated key used for JWT when initializing configuration."`
|
||||
@@ -61,12 +63,12 @@ func defaultConfig() CLI {
|
||||
return CLI{NoConfigFile: false, ConfigFilePath: "bibliomane.toml", DisableStoreJWTKeyInConfig: false, ConfigFile: c}
|
||||
}
|
||||
|
||||
func LoadConfig() Config {
|
||||
func LoadConfig(applicationVersion string) Config {
|
||||
|
||||
var cfg CLI
|
||||
|
||||
//parse first to get config path
|
||||
kong.Parse(&cfg)
|
||||
kong.Parse(&cfg, kong.Vars{"version": fmt.Sprintf("bibliomane v%s", applicationVersion)})
|
||||
|
||||
configPath := cfg.ConfigFilePath
|
||||
|
||||
|
||||
Reference in New Issue
Block a user