fix: clac logging error if first command execution is canceled early (cache file doesn't exist)

Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
Chapman Pendery
2023-09-26 17:42:25 -07:00
parent f6c19f9236
commit a937a000ce
+7 -7
View File
@@ -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]