Files
kopia/internal/server/api_cli.go
2025-05-29 06:07:49 +00:00

29 lines
513 B
Go

package server
import (
"context"
"os"
"strings"
"github.com/kopia/kopia/internal/serverapi"
)
func handleCLIInfo(_ context.Context, rc requestContext) (any, *apiError) {
executable, err := os.Executable()
if err != nil {
executable = "kopia"
}
return &serverapi.CLIInfo{
Executable: maybeQuote(executable) + " --config-file=" + maybeQuote(rc.srv.getOptions().ConfigFile) + "",
}, nil
}
func maybeQuote(s string) string {
if !strings.Contains(s, " ") {
return s
}
return "\"" + s + "\""
}