diff --git a/CHANGELOG.md b/CHANGELOG.md index 658df19..ed1e8bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [Unreleased] + +* Open dump in Explorer/Finder when finished (#43). + ## [v0.2.1] * Display host and database statistics generated by the corresponding diagnostic MongoDB commands in addition to collection stats (#15). @@ -17,6 +21,7 @@ Initial release. +[Unreleased]: https://github.com/garraflavatra/rolens/tree/main [v0.1.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.1.0 [v0.2.0]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.0 [v0.2.1]: https://github.com/garraflavatra/rolens/releases/tag/v0.2.1 diff --git a/internal/app/database_dump.go b/internal/app/database_dump.go index efd426b..21eaf8c 100644 --- a/internal/app/database_dump.go +++ b/internal/app/database_dump.go @@ -43,6 +43,7 @@ func (a *App) PerformDump(jsonData string) bool { args := make([]string, 0) args = append(args, fmt.Sprintf(`--uri="%v"`, host.URI)) + fname := path.Join(info.OutDir, info.Filename) if info.DbKey != "" { args = append(args, fmt.Sprintf(`--db="%v"`, info.DbKey)) @@ -52,7 +53,7 @@ func (a *App) PerformDump(jsonData string) bool { } } - args = append(args, fmt.Sprintf(`--out="%v"`, path.Join(info.OutDir, info.Filename))) + args = append(args, fmt.Sprintf(`--out="%v"`, fname)) cmd := exec.Command("mongodump", args...) var stdout strings.Builder var stderr strings.Builder @@ -63,9 +64,14 @@ func (a *App) PerformDump(jsonData string) bool { runtime.LogInfo(a.ctx, "Performing dump, executing command: mongodump "+strings.Join(args, " ")) runtime.LogInfo(a.ctx, "mongodump stdout: "+stdout.String()) runtime.LogInfo(a.ctx, "mongodump sterr: "+stderr.String()) + if err != nil { runtime.LogWarning(a.ctx, "Error while executing mongodump: "+err.Error()) + return false } - return err == nil + println(fname) + + a.ui.Reveal(fname) + return true }