diff --git a/cmd/offboard/offboard.go b/cmd/offboard/offboard.go index ccb5fac..354a03b 100644 --- a/cmd/offboard/offboard.go +++ b/cmd/offboard/offboard.go @@ -34,7 +34,7 @@ func NewConfigCommand() *cobra.Command { Long: offboardLongDesc, Args: func(_ *cobra.Command, args []string) error { if !(len(args) > 0) { - errors.New("you must provide at least one argument: the offboarding user's email/username") + return errors.New("you must provide at least one argument: the offboarding user's email/username") } opts.offboardingUsers = args diff --git a/cmd/offboard/output.go b/cmd/offboard/output.go index f076838..3563f98 100644 --- a/cmd/offboard/output.go +++ b/cmd/offboard/output.go @@ -63,11 +63,14 @@ func generateOwnersFile(path string, offboardingUsers []string) error { lines := strings.Split(string(owners), "\n") var newLines []string for _, line := range lines { - var result string + newLine := line for _, name := range offboardingUsers { - result, _, _ = strings.Cut(line, "@"+name) + result, _, found := strings.Cut(newLine, "@"+name) + if found { + newLine = result + } } - newLines = append(newLines, result) + newLines = append(newLines, newLine) } output := strings.Join(newLines, "\n")