Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/dbc/driver_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestUnmarshalDriverList(t *testing.T) {
{"less", "[drivers]\nflightsql = {version = '<=1.8.0'}", []dbc.PkgInfo{
{Driver: dbc.Driver{Path: "flightsql"}, Version: semver.MustParse("1.8.0")},
}, nil},
{"greater", "[drivers]\nflightsql = {version = '>=1.8.0'}", []dbc.PkgInfo{
{"greater", "[drivers]\nflightsql = {version = '>=1.8.0, <1.10.0'}", []dbc.PkgInfo{
{Driver: dbc.Driver{Path: "flightsql"}, Version: semver.MustParse("1.9.0")},
}, nil},
}
Expand Down
10 changes: 8 additions & 2 deletions cmd/dbc/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/list"
"github.com/charmbracelet/lipgloss/table"
"github.com/charmbracelet/lipgloss/tree"
"github.com/columnar-tech/dbc"
"github.com/columnar-tech/dbc/config"
Expand Down Expand Up @@ -115,6 +116,8 @@ func viewDrivers(d []dbc.Driver, verbose bool) string {
installedStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("241"))

l := list.New()
t := table.New().Border(lipgloss.HiddenBorder()).
BorderTop(false).BorderBottom(false).BorderLeft(false).BorderRight(false)
for _, driver := range d {
var installed []string
installedVerbose := make(map[string][]string)
Expand All @@ -135,11 +138,11 @@ func viewDrivers(d []dbc.Driver, verbose bool) string {
var regTag string
if driver.Registry.Name != "" {
regTag = registryStyle.Render(" [" + driver.Registry.Name + "]")
suffix += regTag
}

if !verbose {
l.Item(nameStyle.Render(driver.Path) + " - " + descStyle.Render(driver.Desc) + suffix)
t.Row(nameStyle.Render(driver.Path)+regTag,
descStyle.Render(driver.Desc), suffix)
continue
}

Expand Down Expand Up @@ -171,6 +174,9 @@ func viewDrivers(d []dbc.Driver, verbose bool) string {
).Enumerator(emptyEnumerator))
}

if !verbose {
return t.String() + "\n"
}
return l.String() + "\n"
}

Expand Down
26 changes: 14 additions & 12 deletions cmd/dbc/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ func (suite *SubcommandTestSuite) TestSearchCmd() {
m := SearchCmd{}.GetModelCustom(
baseModel{getDriverRegistry: getTestDriverRegistry,
downloadPkg: downloadTestPkg})
suite.validateOutput("\r ", "• test-driver-1 - This is a test driver\n"+
"• test-driver-2 - This is another test driver\n"+
"• test-driver-manifest-only - This is manifest-only driver\n"+
"• test-driver-no-sig - Driver manifest missing Files.signature entry\n"+
"• test-driver-invalid-manifest - This is test driver with an invalid manifest. See https://github.com/columnar-tech/dbc/issues/37.\n"+
"• test-driver-docs-url - This is manifest-only with its docs_url key set\n", suite.runCmd(m))
suite.validateOutput("\r ",
"test-driver-1 This is a test driver \n"+
"test-driver-2 This is another test driver \n"+
"test-driver-manifest-only This is manifest-only driver \n"+
"test-driver-no-sig Driver manifest missing Files.signature entry \n"+
"test-driver-invalid-manifest This is test driver with an invalid manifest. See https://github.com/columnar-tech/dbc/issues/37. \n"+
"test-driver-docs-url This is manifest-only with its docs_url key set \n", suite.runCmd(m))
}

func (suite *SubcommandTestSuite) TestSearchCmdWithInstalled() {
Expand All @@ -40,12 +41,13 @@ func (suite *SubcommandTestSuite) TestSearchCmdWithInstalled() {
m = SearchCmd{}.GetModelCustom(
baseModel{getDriverRegistry: getTestDriverRegistry,
downloadPkg: downloadTestPkg})
suite.validateOutput("\r ", "• test-driver-1 - This is a test driver [installed: env=>1.1.0]\n"+
"• test-driver-2 - This is another test driver\n"+
"• test-driver-manifest-only - This is manifest-only driver\n"+
"• test-driver-no-sig - Driver manifest missing Files.signature entry\n"+
"• test-driver-invalid-manifest - This is test driver with an invalid manifest. See https://github.com/columnar-tech/dbc/issues/37.\n"+
"• test-driver-docs-url - This is manifest-only with its docs_url key set\n", suite.runCmd(m))
suite.validateOutput("\r ",
"test-driver-1 This is a test driver [installed: env=>1.1.0]\n"+
"test-driver-2 This is another test driver \n"+
"test-driver-manifest-only This is manifest-only driver \n"+
"test-driver-no-sig Driver manifest missing Files.signature entry \n"+
"test-driver-invalid-manifest This is test driver with an invalid manifest. See https://github.com/columnar-tech/dbc/issues/37. \n"+
"test-driver-docs-url This is manifest-only with its docs_url key set \n", suite.runCmd(m))
}

func (suite *SubcommandTestSuite) TestSearchCmdVerbose() {
Expand Down
Loading