-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show list of databases if non is selected
- Loading branch information
1 parent
03e77b7
commit 8085b43
Showing
7 changed files
with
140 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package list | ||
|
||
import ( | ||
"github.com/charmbracelet/huh" | ||
"github.com/lewissteele/dbat/internal/db" | ||
) | ||
|
||
func RenderConnectionSelection() string { | ||
var c string | ||
options := []huh.Option[string]{} | ||
|
||
for _, v := range db.UserDBNames() { | ||
options = append(options, huh.NewOption[string](v, v)) | ||
} | ||
|
||
form := huh.NewForm( | ||
huh.NewGroup( | ||
huh.NewSelect[string]().Title("database").Value(&c).Options( | ||
options..., | ||
), | ||
), | ||
) | ||
|
||
err := form.Run() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package list | ||
|
||
import ( | ||
"github.com/charmbracelet/huh" | ||
"github.com/lewissteele/dbat/internal/db" | ||
) | ||
|
||
func RenderDatabaseSelection() string { | ||
var d string | ||
options := []huh.Option[string]{} | ||
|
||
for _, v := range db.Databases() { | ||
options = append(options, huh.NewOption[string](v, v)) | ||
} | ||
|
||
form := huh.NewForm( | ||
huh.NewGroup( | ||
huh.NewSelect[string]().Title("database").Value(&d).Options( | ||
options..., | ||
), | ||
), | ||
) | ||
|
||
err := form.Run() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return d | ||
} |