From a937a000ced42ec80160b982916448025844cd6b Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Tue, 26 Sep 2023 17:42:25 -0700 Subject: [PATCH] fix: clac logging error if first command execution is canceled early (cache file doesn't exist) Signed-off-by: Chapman Pendery --- cmd/root.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1d1f8b5..b4c2f94 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -36,13 +36,6 @@ func init() { } func rootExec(cmd *cobra.Command, args []string) error { - if outputCmd { - result := autocomplete.ReadResult() - _, err := os.Stdout.WriteString(result) - return err - } - autocomplete.ClearResult() - if enableLogging { f, err := tea.LogToFile("clac.log", "debug") if err != nil { @@ -53,6 +46,13 @@ func rootExec(cmd *cobra.Command, args []string) error { slog.SetDefault(slog.New(slog.NewTextHandler(io.Discard, nil))) } + if outputCmd { + result := autocomplete.ReadResult() + _, err := os.Stdout.WriteString(result) + return err + } + autocomplete.ClearResult() + startingInput := "" if len(args) >= 1 { startingInput = args[0]