summaryrefslogtreecommitdiff
path: root/internal/askcli/command_fish.go
blob: f4ca9e0d8bafef59a7ab93c3e3c58de8dce034e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package askcli

import (
	"context"
	"fmt"
	"io"
	"os"
)

func (d *Dispatcher) handleFish(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) {
	_ = ctx
	if len(args) != 1 {
		fmt.Fprintln(stderr, "usage: ask fish")
		return 1, nil
	}
	binaryPath, err := os.Executable()
	if err != nil {
		binaryPath = "ask"
	}
	if _, err := io.WriteString(stdout, FishCompletionFor(binaryPath)); err != nil {
		return 1, err
	}
	return 0, nil
}