1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-06-28 05:25:11 +00:00

Add option to save shell output

This commit is contained in:
2023-12-22 15:56:00 +01:00
parent 82b8f1e300
commit 773bcf65fd
4 changed files with 42 additions and 1 deletions

View File

@ -182,3 +182,30 @@ func (a *App) OpenShellScript() string {
return string(script)
}
func (a *App) SaveShellOuput(output string) {
fname, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{
DefaultFilename: "mongosh-output.txt",
DefaultDirectory: a.Env.DownloadDirectory,
Title: "Save mongosh output",
CanCreateDirectories: true,
})
if err != nil {
runtime.LogWarningf(a.ctx, "Shell: error exporting output to %s: %s", fname, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Title: "Error exporting output",
Message: err.Error(),
Type: runtime.ErrorDialog,
})
}
if err := os.WriteFile(fname, []byte(output), os.ModePerm); err != nil {
runtime.LogWarningf(a.ctx, "Shell: error writing shell output to %s: %s", fname, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Title: "Error writing shell output",
Message: err.Error(),
Type: runtime.ErrorDialog,
})
}
}