completion.go 675 B

12345678910111213141516171819202122232425262728293031323334
  1. package task
  2. import (
  3. _ "embed"
  4. "fmt"
  5. )
  6. //go:embed completion/bash/task.bash
  7. var completionBash string
  8. //go:embed completion/fish/task.fish
  9. var completionFish string
  10. //go:embed completion/ps/task.ps1
  11. var completionPowershell string
  12. //go:embed completion/zsh/_task
  13. var completionZsh string
  14. func Completion(completion string) (string, error) {
  15. // Get the file extension for the selected shell
  16. switch completion {
  17. case "bash":
  18. return completionBash, nil
  19. case "fish":
  20. return completionFish, nil
  21. case "powershell":
  22. return completionPowershell, nil
  23. case "zsh":
  24. return completionZsh, nil
  25. default:
  26. return "", fmt.Errorf("unknown shell: %s", completion)
  27. }
  28. }