mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-24 09:35:42 +00:00
parent
df26a3eeb7
commit
d6b0062ae9
2 changed files with 17 additions and 2 deletions
|
@ -35,6 +35,15 @@ var (
|
||||||
buildTime = "now"
|
buildTime = "now"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func build() string {
|
||||||
|
short := commit
|
||||||
|
if len(short) > 7 {
|
||||||
|
short = short[:7]
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s, commit %s, built at %s", version, short, buildTime)
|
||||||
|
}
|
||||||
|
|
||||||
// @title Homebox API
|
// @title Homebox API
|
||||||
// @version 1.0
|
// @version 1.0
|
||||||
// @description Track, Manage, and Organize your Things.
|
// @description Track, Manage, and Organize your Things.
|
||||||
|
@ -47,7 +56,7 @@ var (
|
||||||
func main() {
|
func main() {
|
||||||
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
|
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
|
||||||
|
|
||||||
cfg, err := config.New()
|
cfg, err := config.New(build(), "Homebox inventory management system")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
conf.Version
|
||||||
Mode string `yaml:"mode" conf:"default:development"` // development or production
|
Mode string `yaml:"mode" conf:"default:development"` // development or production
|
||||||
Web WebConfig `yaml:"web"`
|
Web WebConfig `yaml:"web"`
|
||||||
Storage Storage `yaml:"storage"`
|
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
|
// 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.
|
// 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
|
var cfg Config
|
||||||
const prefix = "HBOX"
|
const prefix = "HBOX"
|
||||||
|
|
||||||
|
cfg.Version = conf.Version{
|
||||||
|
Build: buildstr,
|
||||||
|
Desc: description,
|
||||||
|
}
|
||||||
|
|
||||||
help, err := conf.Parse(prefix, &cfg)
|
help, err := conf.Parse(prefix, &cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, conf.ErrHelpWanted) {
|
if errors.Is(err, conf.ErrHelpWanted) {
|
||||||
|
|
Loading…
Reference in a new issue