Skip to content

Commit

Permalink
Add check if an app version was given
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Jan 20, 2023
1 parent 62987b8 commit bd610a6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func New(name string, version string, optionalOptions ...Option) *App {
appOpts.apply(defaultOptions...)
appOpts.apply(optionalOptions...)

if strings.HasPrefix(strings.ToLower(version), "v") {
if _, err := goversion.NewSemver(version[1:]); err == nil {
// version is a valid SemVer with a "v" prefix => remove the "v" prefix
version = version[1:]
}
}

if version == "" {
panic("unable to initialize app: no version given")
}

a := &App{
appInfo: &Info{
Name: name,
Expand Down Expand Up @@ -111,7 +122,7 @@ func (a *App) init() {
helpFull := flag.Bool("full", false, "prints full app help (only in combination with -h)")

if a.options.initComponent == nil {
panic("you must configure the app with an InitComponent")
panic("unable to initialize app: no InitComponent given")
}

// default config
Expand Down

0 comments on commit bd610a6

Please sign in to comment.