Skip to content
Closed
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
27 changes: 15 additions & 12 deletions cli/cmd/encore/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/signal"

"github.com/spf13/cobra"
"golang.org/x/term"

"encr.dev/cli/cmd/encore/cmdutil"
"encr.dev/cli/cmd/encore/root"
Expand Down Expand Up @@ -66,12 +67,13 @@ func execScript(appRoot, relWD string, args []string) {
defer func() { _ = os.RemoveAll(tempDir) }()

stream, err := daemon.ExecSpec(ctx, &daemonpb.ExecSpecRequest{
AppRoot: appRoot,
WorkingDir: relWD,
ScriptArgs: args,
Environ: os.Environ(),
Namespace: nonZeroPtr(nsName),
TempDir: tempDir,
AppRoot: appRoot,
WorkingDir: relWD,
ScriptArgs: args,
Environ: os.Environ(),
Namespace: nonZeroPtr(nsName),
TempDir: tempDir,
NonInteractive: !term.IsTerminal(int(os.Stderr.Fd())),
})
if err != nil {
fatal(err)
Expand Down Expand Up @@ -120,12 +122,13 @@ func execScript(appRoot, relWD string, args []string) {

// For Go apps, use the streaming ExecScript RPC.
stream, err := daemon.ExecScript(ctx, &daemonpb.ExecScriptRequest{
AppRoot: appRoot,
WorkingDir: relWD,
ScriptArgs: args,
Environ: os.Environ(),
TraceFile: root.TraceFile,
Namespace: nonZeroPtr(nsName),
AppRoot: appRoot,
WorkingDir: relWD,
ScriptArgs: args,
Environ: os.Environ(),
TraceFile: root.TraceFile,
Namespace: nonZeroPtr(nsName),
NonInteractive: !term.IsTerminal(int(os.Stderr.Fd())),
})
if err != nil {
fatal(err)
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/encore/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func runApp(appRoot, wd string) {
Browser: browserMode,
LogLevel: nonZeroPtr(logLevel.Value),
ScrubSensitiveData: scrubSensitiveData,
NonInteractive: !term.IsTerminal(int(os.Stderr.Fd())),
})
if err != nil {
fatal(err)
Expand Down
14 changes: 12 additions & 2 deletions cli/daemon/exec_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ func (s *Server) ExecScript(req *daemonpb.ExecScriptRequest, stream daemonpb.Dae
return nil
}

ops := optracker.New(stderr, stream)
var ops *optracker.OpTracker
if req.NonInteractive {
ops = optracker.NewLineMode(stderr)
} else {
ops = optracker.New(stderr, stream)
}
defer ops.AllDone() // Kill the tracker when we exit this function

testResults := make(chan error, 1)
Expand Down Expand Up @@ -163,7 +168,12 @@ func (s *Server) ExecSpec(req *daemonpb.ExecSpecRequest, stream daemonpb.Daemon_
return nil
}

ops := optracker.New(stderr, adapter)
var ops *optracker.OpTracker
if req.NonInteractive {
ops = optracker.NewLineMode(stderr)
} else {
ops = optracker.New(stderr, adapter)
}
defer ops.AllDone()

defer func() {
Expand Down
7 changes: 6 additions & 1 deletion cli/daemon/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ func (s *Server) Run(req *daemonpb.RunRequest, stream daemonpb.Daemon_RunServer)
return nil
}

ops := optracker.New(stderr, stream)
var ops *optracker.OpTracker
if req.NonInteractive {
ops = optracker.NewLineMode(stderr)
} else {
ops = optracker.New(stderr, stream)
}
defer ops.AllDone() // Kill the tracker when we exit this function

// Check for available update before we start the proc
Expand Down
66 changes: 50 additions & 16 deletions proto/encore/daemon/daemon.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions proto/encore/daemon/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ message RunRequest {
// scrub_sensitive_data, if true, scrubs sensitive data from local traces.
bool scrub_sensitive_data = 13;

// non_interactive, if true, signals that the CLI is not connected to an
// interactive terminal. The build progress UI is rendered as plain
// one-line-per-event output instead of the spinner.
bool non_interactive = 14;

enum BrowserMode {
BROWSER_AUTO = 0;
BROWSER_NEVER = 1;
Expand Down Expand Up @@ -262,6 +267,10 @@ message ExecScriptRequest {
// namespace is the infrastructure namespace to use.
// If empty the active namespace is used.
optional string namespace = 7;

// non_interactive, if true, signals that the CLI is not connected to an
// interactive terminal. See RunRequest.non_interactive for details.
bool non_interactive = 8;
}

message ExecSpecRequest {
Expand All @@ -280,6 +289,10 @@ message ExecSpecRequest {
// temp_dir is a temp dir that will be cleaned up by the CLI after the command
// has been executed, to write things like app meta and runtime config etc.
string temp_dir = 8;

// non_interactive, if true, signals that the CLI is not connected to an
// interactive terminal. See RunRequest.non_interactive for details.
bool non_interactive = 9;
}

message ExecSpecMessage {
Expand Down