Skip to content

Commit

Permalink
Open dump in Explorer/Finder when finished (fixes #43)
Browse files Browse the repository at this point in the history
  • Loading branch information
garraflavatra committed Jun 24, 2023
1 parent 8f81e66 commit 3e29391
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -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
10 changes: 8 additions & 2 deletions internal/app/database_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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
}

0 comments on commit 3e29391

Please sign in to comment.