feat: set version flag (#632)

This commit is contained in:
Hayden 2023-11-24 13:02:02 -06:00 committed by GitHub
parent 8cc0f30291
commit 9edbda3daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -15,6 +15,7 @@ const (
)
type Config struct {
conf.Version
Mode string `yaml:"mode" conf:"default:development"` // development or production
Web WebConfig `yaml:"web"`
Storage Storage `yaml:"storage"`
@ -46,10 +47,15 @@ type WebConfig struct {
// New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the
// file is not read. If the file is not empty, the file is read and the Config struct is returned.
func New() (*Config, error) {
func New(buildstr string, description string) (*Config, error) {
var cfg Config
const prefix = "HBOX"
cfg.Version = conf.Version{
Build: buildstr,
Desc: description,
}
help, err := conf.Parse(prefix, &cfg)
if err != nil {
if errors.Is(err, conf.ErrHelpWanted) {