Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanndickson committed Aug 12, 2024
1 parent 02a2802 commit 20f9762
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions completion/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,30 @@ func generateCompletion(
func InstallShellCompletion(shell Shell) error {
path, err := shell.InstallPath()
if err != nil {
return fmt.Errorf("failed to get install path: %w", err)
return fmt.Errorf("get install path: %w", err)
}

err = os.MkdirAll(filepath.Dir(path), 0o755)
if err != nil {
return fmt.Errorf("failed to create directories: %w", err)
return fmt.Errorf("create directories: %w", err)
}

if shell.UsesOwnFile() {
err := os.WriteFile(path, nil, 0o644)
if err != nil {
return fmt.Errorf("failed to create or truncate file: %w", err)
return fmt.Errorf("create file: %w", err)
}
}

f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
return fmt.Errorf("failed to open file for appending: %w", err)
return fmt.Errorf("open file for appending: %w", err)
}
defer f.Close()

err = shell.WriteCompletion(f)
if err != nil {
return fmt.Errorf("failed to write completion script: %w", err)
return fmt.Errorf("write completion script: %w", err)
}

return nil
Expand Down

0 comments on commit 20f9762

Please # to comment.