diff --git a/frontend/src/organisms/connection/shell.svelte b/frontend/src/organisms/connection/shell.svelte
index 3e4d62f..605e45a 100644
--- a/frontend/src/organisms/connection/shell.svelte
+++ b/frontend/src/organisms/connection/shell.svelte
@@ -77,11 +77,15 @@
{:else}
-
{result.output || ''}
+ {result.output || ''}{#if result.stderr}{result.stderr}
{/if}
{/if}
+
+
{#key result}
{#if result?.status}
@@ -89,10 +93,6 @@
{/if}
{/key}
-
-
@@ -114,7 +114,7 @@
}
.output {
- background-color: #111;
+ background-color: #2e3027;
color: #fff;
overflow: auto;
display: flex;
@@ -129,6 +129,10 @@
-webkit-user-select: text;
cursor: text;
}
+ .output pre .error {
+ color: #ff8989;
+ margin-top: 2px;
+ }
.output :global(.blankstate) {
margin: auto;
padding: 0.5rem;
@@ -141,6 +145,6 @@
grid-column: 1 / 3;
}
.controls .status {
- margin-right: auto;
+ margin-left: auto;
}
diff --git a/internal/app/host_shell.go b/internal/app/host_shell.go
index 9b27c07..9a4a9ad 100644
--- a/internal/app/host_shell.go
+++ b/internal/app/host_shell.go
@@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path"
+ "strings"
"github.com/google/uuid"
"github.com/wailsapp/wails/v2/pkg/runtime"
@@ -13,6 +14,7 @@ import (
type ExecuteShellScriptResult struct {
Output string `json:"output"`
+ Stderr string `json:"stderr"`
Status int `json:"status"`
ErrorTitle string `json:"errorTitle"`
ErrorDescription string `json:"errorDescription"`
@@ -85,14 +87,17 @@ func (a *App) ExecuteShellScript(hostKey, dbKey, collKey, script string) (result
return
}
+ var outbuf, errbuf strings.Builder
cmd := exec.Command("mongosh", "--file", fname, host.URI)
- stdout, err := cmd.Output()
+ cmd.Stdout = &outbuf
+ cmd.Stderr = &errbuf
+ err = cmd.Run()
if exiterr, ok := err.(*exec.ExitError); ok {
result.Status = exiterr.ExitCode()
} else if err != nil {
runtime.LogWarningf(a.ctx, "Shell: failed to execute: mongosh --file %s: %s", fname, err.Error())
- result.ErrorTitle = "Could not execute script"
+ result.ErrorTitle = "mongosh failure"
result.ErrorDescription = err.Error()
return
} else {
@@ -100,6 +105,7 @@ func (a *App) ExecuteShellScript(hostKey, dbKey, collKey, script string) (result
}
os.Remove(fname)
- result.Output = string(stdout)
+ result.Output = outbuf.String()
+ result.Stderr = errbuf.String()
return
}