MCPcopy Create free account
hub / github.com/celer-pkg/celer / installCompletion

Method installCompletion

completion/zsh.go:87–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87func (z zsh) installCompletion() error {
88 if err := dirs.CleanTmpFilesDir(); err != nil {
89 return fmt.Errorf("failed to clean tmp files dir -> %w", err)
90 }
91
92 // Generate completion file.
93 filePath := filepath.Join(dirs.TmpFilesDir, "celer")
94 file, err := os.Create(filePath)
95 if err != nil {
96 return fmt.Errorf("failed to create zsh completion file -> %w", err)
97 }
98 defer file.Close()
99
100 if err := z.rootCmd.GenZshCompletion(file); err != nil {
101 return fmt.Errorf("failed to generate zsh completion file -> %w", err)
102 }
103
104 // Install completion file to `~/.local/share/zsh/site-functions/_celer`
105 destination := filepath.Join(z.homeDir, ".local", "share", "zsh", "site-functions", "_celer")
106 if err := os.MkdirAll(filepath.Dir(destination), os.ModePerm); err != nil {
107 return err
108 }
109 if err := fileio.MoveFile(filePath, destination); err != nil {
110 return err
111 }
112
113 if err := z.registerRunCommand(); err != nil {
114 return err
115 }
116
117 fmt.Printf("[integrate] completion --> %s\n", destination)
118 return nil
119}
120
121func (z zsh) uninstallCompletion() error {
122 fmt.Println("[integrate] rm -f ~/.local/share/zsh/site-functions/_celer")

Callers 1

RegisterMethod · 0.95

Calls 4

registerRunCommandMethod · 0.95
CleanTmpFilesDirFunction · 0.92
MoveFileFunction · 0.92
MkdirAllMethod · 0.80

Tested by

no test coverage detected