2024-09-02 20:21:53 +01:00
|
|
|
package task
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
_ "embed"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//go:embed completion/bash/task.bash
|
|
|
|
|
var completionBash string
|
|
|
|
|
|
|
|
|
|
//go:embed completion/fish/task.fish
|
|
|
|
|
var completionFish string
|
|
|
|
|
|
2026-08-11 20:12:17 +02:00
|
|
|
//go:embed completion/nu/task-completions.nu
|
|
|
|
|
var completionNu string
|
|
|
|
|
|
2024-09-02 20:21:53 +01:00
|
|
|
//go:embed completion/ps/task.ps1
|
|
|
|
|
var completionPowershell string
|
|
|
|
|
|
|
|
|
|
//go:embed completion/zsh/_task
|
|
|
|
|
var completionZsh string
|
|
|
|
|
|
|
|
|
|
func Completion(completion string) (string, error) {
|
|
|
|
|
// Get the file extension for the selected shell
|
|
|
|
|
switch completion {
|
|
|
|
|
case "bash":
|
|
|
|
|
return completionBash, nil
|
|
|
|
|
case "fish":
|
|
|
|
|
return completionFish, nil
|
2026-08-11 20:12:17 +02:00
|
|
|
case "nu", "nushell":
|
|
|
|
|
return completionNu, nil
|
2024-09-02 20:21:53 +01:00
|
|
|
case "powershell":
|
|
|
|
|
return completionPowershell, nil
|
|
|
|
|
case "zsh":
|
|
|
|
|
return completionZsh, nil
|
|
|
|
|
default:
|
|
|
|
|
return "", fmt.Errorf("unknown shell: %s", completion)
|
|
|
|
|
}
|
|
|
|
|
}
|