You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 548B

1234567891011121314151617181920212223242526
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package cmd
  4. import (
  5. "fmt"
  6. "strings"
  7. "github.com/urfave/cli"
  8. )
  9. func RunMainApp(app *cli.App, args ...string) error {
  10. err := app.Run(args)
  11. if err == nil {
  12. return nil
  13. }
  14. if strings.HasPrefix(err.Error(), "flag provided but not defined:") {
  15. // the cli package should already have output the error message, so just exit
  16. cli.OsExiter(1)
  17. return err
  18. }
  19. _, _ = fmt.Fprintf(app.ErrWriter, "Command error: %v\n", err)
  20. cli.OsExiter(1)
  21. return err
  22. }