diff options
Diffstat (limited to 'completion/completion.go')
| -rw-r--r-- | completion/completion.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/completion/completion.go b/completion/completion.go index 9d3ae72..0fbe877 100644 --- a/completion/completion.go +++ b/completion/completion.go @@ -35,23 +35,23 @@ var completionFileByShell = map[string]string{ var AlreadyInstalledError = errors.New("completion already installed") // Add finds the right file to append the completion code to and does that -func Add(shell string) error { +func Add(shell string) *spool.ExitCode { f := filepath.Join(paths.HomeDir.String(), completionFileByShell[shell]) content, err := os.ReadFile(f) if err != nil { - return err + return &spool.FatalReadFailure } if strings.Contains(string(content), strings.TrimSpace(completionCodeByShell[shell])) { - return AlreadyInstalledError + return &spool.CompletionAlreadyInstalledFailure } fd, err := os.OpenFile(f, os.O_APPEND|os.O_WRONLY, 0600) defer fd.Close() if err != nil { - return err + return &spool.FatalReadFailure } _, err = fd.Write([]byte(fmt.Sprintf(completionFormat, completionComment, completionCodeByShell[shell]))) if err != nil { - return err + return &spool.CompletionFailure } successMessage(shell, f) return nil @@ -63,7 +63,7 @@ func successMessage(shell string, file string) { // Echo prints the actual completion script // because it is baked in with the program it should always be version-appropriate -func Echo() error { - _, err := spool.Print("%s", completionCode) - return err +func Echo() *spool.ExitCode { + _, _ = spool.Print("%s", completionCode) + return nil } |
