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

     1  package domainTable
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/jedib0t/go-pretty/v6/table"
     8  	"github.com/pterm/pterm"
     9  	client "github.com/taubyte/tau/clients/http/auth"
    10  )
    11  
    12  func Registered(fqdn string, resp client.DomainResponse) {
    13  	pterm.Info.Printfln("Be sure to the following entries of `%s` to your DNS zone:", fqdn)
    14  	fmt.Println(GetRegisterTable(resp))
    15  }
    16  
    17  func GetRegisterTable(response client.DomainResponse) string {
    18  	t := table.NewWriter()
    19  	t.SetColumnConfigs([]table.ColumnConfig{
    20  		{
    21  			Number:   1,
    22  			WidthMax: 40,
    23  		},
    24  	})
    25  
    26  	t.AppendHeader(table.Row{"Domain Registration"})
    27  	t.AppendSeparator()
    28  	t.AppendRow(table.Row{"Entry", response.Entry})
    29  	t.AppendSeparator()
    30  	t.AppendRow(table.Row{"Type", response.Type})
    31  	t.AppendSeparator()
    32  
    33  	t.SetStyle(table.Style{
    34  		Box: table.StyleBoxDefault,
    35  	})
    36  
    37  	t.AppendRow(table.Row{"Value"}, table.RowConfig{AutoMerge: true})
    38  	t.AppendRow(table.Row{""}, table.RowConfig{AutoMerge: true})
    39  	rendering := t.Render()
    40  	rendering += "\n" + response.Token + "\n" + strings.Repeat("-", 49)
    41  
    42  	return rendering
    43  }