From 46d032cd21b0e8e2c94a32333d3805ec76980cca Mon Sep 17 00:00:00 2001 From: ewy Date: Mon, 1 Jun 2026 18:47:44 +0200 Subject: add man(1) generation --- completion/completion.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'completion') 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 } -- cgit v1.3.1