Skip to content

Commit

Permalink
feat: change withGlobalFlag can return error
Browse files Browse the repository at this point in the history
  • Loading branch information
sinlov committed Jul 17, 2023
1 parent a67343f commit 3dd09af
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c *GlobalCommand) globalExec() error {
// withGlobalFlag
//
// bind global flag to globalExec
func withGlobalFlag(c *cli.Context, cliVersion, cliName string) *GlobalCommand {
func withGlobalFlag(c *cli.Context, cliVersion, cliName string) (*GlobalCommand, error) {
slog.Debug("-> withGlobalFlag")

isVerbose := c.Bool("verbose")
Expand All @@ -63,7 +63,7 @@ func withGlobalFlag(c *cli.Context, cliVersion, cliName string) *GlobalCommand {
Verbose: isVerbose,
RootCfg: config,
}
return &p
return &p, nil
}

// GlobalBeforeAction
Expand All @@ -79,7 +79,10 @@ func GlobalBeforeAction(c *cli.Context) error {
slog.Warnf("-> open verbose, and now command version is: %s", cliVersion)
}
appName := pkgJson.GetPackageJsonName()
cmdGlobalEntry = withGlobalFlag(c, cliVersion, appName)
cmdGlobalEntry, err = withGlobalFlag(c, cliVersion, appName)
if err != nil {
return err
}

return nil
}
Expand Down

0 comments on commit 3dd09af

Please sign in to comment.