Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/internal/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TUIEnabled(ctx *context.Context, cmd *cobra.Command) bool {
format := flags.ValueFor[string](cmd, *flags.OutputFormatFlag, false)
formatDisabled = format == "yaml" || format == "yml" || format == "json"
}
envDisabled, _ := strconv.ParseBool(os.Getenv("DISABLE_FLOW_INTERACTIVE"))
envDisabled, _ := strconv.ParseBool(os.Getenv(flowIO.DisableInteractiveEnvKey))
return !formatDisabled && !envDisabled && ctx.Config.ShowTUI()
}

Expand Down
3 changes: 2 additions & 1 deletion internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package io

import "os"

const DisableInteractiveEnvKey = "DISABLE_FLOW_INTERACTIVE"

var (
Stdout = os.Stdout
Stderr = os.Stderr
Stdin = os.Stdin
)
10 changes: 9 additions & 1 deletion internal/runner/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"gopkg.in/yaml.v3"

"github.com/flowexec/flow/internal/context"
"github.com/flowexec/flow/internal/io"
"github.com/flowexec/flow/internal/logger"
"github.com/flowexec/flow/internal/runner"
"github.com/flowexec/flow/internal/runner/engine"
Expand Down Expand Up @@ -107,7 +108,13 @@ func (r *renderRunner) Exec(
}

logger.Log().Infof("Rendering content from file %s", contentFile)
filename := filepath.Base(contentFile)

if os.Getenv(io.DisableInteractiveEnvKey) != "" {
logger.Log().Print("### Rendered Content Start ###")
logger.Log().Print(buff.String())
logger.Log().Print("### Rendered Content End ###")
return nil
}

if err := ctx.TUIContainer.Start(); err != nil {
return errors.Wrapf(err, "unable to open viewer")
Expand All @@ -116,6 +123,7 @@ func (r *renderRunner) Exec(
ctx.TUIContainer.WaitForExit()
}()

filename := filepath.Base(contentFile)
ctx.TUIContainer.SetState("file", filename)
return ctx.TUIContainer.SetView(views.NewMarkdownView(ctx.TUIContainer.RenderState(), buff.String()))
}
Expand Down
7 changes: 4 additions & 3 deletions internal/utils/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/flowexec/flow/internal/context"
"github.com/flowexec/flow/internal/filesystem"
"github.com/flowexec/flow/internal/io"
"github.com/flowexec/flow/internal/utils"
"github.com/flowexec/flow/types/executable"
)
Expand Down Expand Up @@ -206,9 +207,9 @@ func DefaultEnv(ctx *context.Context, executable *executable.Executable) map[str
envMap["FLOW_WORKSPACE_PATH"] = executable.WorkspacePath()
envMap["FLOW_CONFIG_PATH"] = filesystem.ConfigDirPath()
envMap["FLOW_CACHE_PATH"] = filesystem.CachedDataDirPath()
envMap["DISABLE_FLOW_INTERACTIVE"] = "true"
if interactive := os.Getenv("DISABLE_FLOW_INTERACTIVE"); interactive != "" {
envMap["DISABLE_FLOW_INTERACTIVE"] = interactive
envMap[io.DisableInteractiveEnvKey] = "true"
if interactive := os.Getenv(io.DisableInteractiveEnvKey); interactive != "" {
envMap[io.DisableInteractiveEnvKey] = interactive
}
return envMap
}
Expand Down
3 changes: 2 additions & 1 deletion internal/utils/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"go.uber.org/mock/gomock"

"github.com/flowexec/flow/internal/context"
"github.com/flowexec/flow/internal/io"
"github.com/flowexec/flow/internal/logger"
"github.com/flowexec/flow/internal/utils/env"
"github.com/flowexec/flow/types/config"
Expand Down Expand Up @@ -300,7 +301,7 @@ var _ = Describe("Env", func() {
Expect(envMap["FLOW_CURRENT_WORKSPACE"]).To(Equal(wsName))
Expect(envMap["FLOW_CURRENT_NAMESPACE"]).To(Equal(nsName))
Expect(envMap["FLOW_EXECUTABLE_NAME"]).To(Equal(execName))
Expect(envMap["DISABLE_FLOW_INTERACTIVE"]).To(Equal("true"))
Expect(envMap[io.DisableInteractiveEnvKey]).To(Equal("true"))
// TODO: Add more assertions for other keys in the environment map
})
})
Expand Down