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:
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user