github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/table/project/query.go (about)

     1  package projectTable
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/jedib0t/go-pretty/v6/table"
     7  	projectLib "github.com/taubyte/tau-cli/lib/project"
     8  	client "github.com/taubyte/tau/clients/http/auth"
     9  )
    10  
    11  func Query(project *client.Project, repos *client.RawRepoDataOuter, description string) {
    12  	t := table.NewWriter()
    13  
    14  	colConfigs := make([]table.ColumnConfig, 0)
    15  	colConfigs = append(colConfigs, table.ColumnConfig{
    16  		Number:   2,
    17  		WidthMax: 55,
    18  	})
    19  	t.SetColumnConfigs(colConfigs)
    20  	t.SetOutputMirror(os.Stdout)
    21  
    22  	// Basic information
    23  	t.AppendRow(table.Row{"ID", project.Id})
    24  	t.AppendSeparator()
    25  	t.AppendRow(table.Row{"Name", project.Name})
    26  	t.AppendSeparator()
    27  	t.AppendRow(table.Row{"Description", description})
    28  	t.AppendSeparator()
    29  
    30  	// Repository information
    31  	t.AppendRow(table.Row{"", "Code"})
    32  	t.AppendRow(table.Row{"Name:", repos.Code.Fullname})
    33  	t.AppendRow(table.Row{"URL:", projectLib.CleanGitURL(repos.Code.Url)})
    34  	t.AppendSeparator()
    35  	t.AppendRow(table.Row{"", "Config"})
    36  	t.AppendRow(table.Row{"Name:", repos.Configuration.Fullname})
    37  	t.AppendRow(table.Row{"URL:", projectLib.CleanGitURL(repos.Configuration.Url)})
    38  
    39  	// Render
    40  	t.SetStyle(table.StyleLight)
    41  	t.Render()
    42  }