diff options
| author | ewy <ewy0@protonmail.com> | 2026-06-01 18:47:44 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-06-01 18:47:44 +0200 |
| commit | 46d032cd21b0e8e2c94a32333d3805ec76980cca (patch) | |
| tree | fbb8aed5c5a501aca1309f62a9d4440ca949ce4c /completion | |
| parent | 7585a488b7b1e1812f7ebf50107139e2fd65f035 (diff) | |
add man(1) generation
Diffstat (limited to 'completion')
| -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 } |
