GitOps for k8s
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.

error.go 577B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "errors"
  4. )
  5. type usageError struct {
  6. error
  7. }
  8. func newUsageError(msg string) usageError {
  9. return usageError{error: errors.New(msg)}
  10. }
  11. func checkExactlyOne(optsDescription string, supplied ...bool) error {
  12. found := false
  13. for _, s := range supplied {
  14. if found && s {
  15. return newUsageError("please supply only one of " + optsDescription)
  16. }
  17. found = found || s
  18. }
  19. if !found {
  20. return newUsageError("please supply exactly one of " + optsDescription)
  21. }
  22. return nil
  23. }
  24. var errorWantedNoArgs = newUsageError("expected no (non-flag) arguments")