cli_ui

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const CloudTokenRequestPath = "/Settings/accessTokens"

CloudTokenRequestPath What is the request path to obtain the cloud token If there is a change in the address of the cloud side, synchronize it here

View Source
const DefaultSelectProvidersTitle = "[ Use arrows to move, Space to select, Enter to complete the selection ]"

Variables

View Source
var (
	YellowColor  = color.New(color.FgYellow).SprintFunc()
	RedColor     = color.New(color.FgRed).SprintFunc()
	GreenColor   = color.New(color.FgGreen).SprintFunc()
	BlueColor    = color.New(color.FgBlue).SprintFunc()
	MagentaColor = color.New(color.FgMagenta).SprintFunc()
	BlackColor   = color.New(color.FgBlack).SprintFunc()
	CyanColor    = color.New(color.FgCyan).SprintFunc()
	WhiteColor   = color.New(color.FgWhite).SprintFunc()
)
View Source
var (
	ErrorColor   = color.New(color.FgRed, color.Bold)
	WarningColor = color.New(color.FgYellow, color.Bold)
	//InfoColor    = color.New(color.FgWhite, color.Bold)
	InfoColor    *color.Color = nil
	SuccessColor              = color.New(color.FgGreen, color.Bold)
)

Functions

func Errorf

func Errorf(format string, a ...interface{})

func Errorln

func Errorln(a ...interface{})

func Infof

func Infof(format string, a ...interface{})

Infof info without color

func Infoln

func Infoln(a ...interface{})

func InputCloudToken

func InputCloudToken(serverUrl string) (string, *schema.Diagnostics)

InputCloudToken Guide the user to enter a cloud token

func PrintDiagnostic

func PrintDiagnostic(diagnostics []*schema.Diagnostic) error

func PrintDiagnostics

func PrintDiagnostics(diagnostics *schema.Diagnostics) error

func Printf

func Printf(c *color.Color, format string, a ...any)

func Println

func Println(c *color.Color, a ...any)

func SDKLogLevelToCliLevel added in v0.0.19

func SDKLogLevelToCliLevel(level schema.DiagnosticLevel) hclog.Level

func SaveLogToDiagnostic

func SaveLogToDiagnostic(diagnostics []*schema.Diagnostic)

func SelectProviders

func SelectProviders(providers []string, title ...string) map[string]struct{}

SelectProviders Give a list of providers and let the user select some of them Does the installation sequence have to be consistent with the selected sequence? Temporarily, I think it can be inconsistent

func ShowDesc

func ShowDesc(bar *Bar, wcc ...decor.WC) decor.Decorator

func ShowLoginFailed

func ShowLoginFailed(cloudToken string)

ShowLoginFailed Displays a login failure message

func ShowLoginSuccess

func ShowLoginSuccess(serverUrl string, cloudCredentials *cloud_sdk.CloudCredentials)

ShowLoginSuccess The CLI prompt indicating successful login is displayed

func ShowLogout

func ShowLogout(cloudCredentials *cloud_sdk.CloudCredentials)

ShowLogout Display the logout success prompt

func ShowRetrievedCloudCredentials

func ShowRetrievedCloudCredentials(cloudCredentials *cloud_sdk.CloudCredentials)

ShowRetrievedCloudCredentials Displays the results of the local retrieval of login credentials

func ShowRows

func ShowRows(tableHeader []string, tableBodyMatrix [][]string, tableFooter []string, setBorder bool)

ShowRows Display the table on the console TODO refactor function

Example
tableHeader := []string{
	"id", "name", "age",
}
tableBody := [][]string{
	{
		"1", "Tom", "18",
	},
	{
		"2", "Ada", "26",
	},
	{
		"3", "Sam", "30",
	},
}
tableFooter := []string{
	"footer1", "footer2", "footer",
}
setBorder := true
ShowRows(tableHeader, tableBody, tableFooter, setBorder)
Output:

*********** Row 0 **********

	  id:	1
	name:	Tom
	 age:	18

*********** Row 1 **********

	  id:	2
	name:	Ada
	 age:	26

*********** Row 2 **********

	  id:	3
	name:	Sam
	 age:	30

func ShowTable

func ShowTable(tableHeader []string, tableBody [][]string, tableFooter []string, setBorder bool)

ShowTable Shows which tables are currently available

Example
tableHeader := []string{
	"id", "name", "age",
}
tableBody := [][]string{
	{
		"1", "Tom", "18",
	},
	{
		"2", "Ada", "26",
	},
	{
		"3", "Sam", "30",
	},
}
tableFooter := []string{
	"footer1", "footer2", "footer",
}
setBorder := true
ShowTable(tableHeader, tableBody, tableFooter, setBorder)
Output:

+---------+---------+--------+
|   ID    |  NAME   |  AGE   |
+---------+---------+--------+
|       1 | Tom     |     18 |
|       2 | Ada     |     26 |
|       3 | Sam     |     30 |
+---------+---------+--------+
| FOOTER1 | FOOTER2 | FOOTER |
+---------+---------+--------+

func Successf

func Successf(format string, a ...interface{})

func Successln

func Successln(a ...interface{})

func Warningf

func Warningf(format string, a ...interface{})

func Warningln

func Warningln(a ...interface{})

Types

type Bar

type Bar struct {
	Name    string
	Desc    string
	Start   time.Time
	Current time.Time
	// contains filtered or unexported fields
}

Bar represents a progress bar

type LogJSON

type LogJSON struct {
	Cmd   string    `json:"cmd"`
	Stag  string    `json:"stag"`
	Msg   string    `json:"msg"`
	Time  time.Time `json:"time"`
	Level string    `json:"level"`
}

type Progress

type Progress struct {
	// contains filtered or unexported fields
}

Progress is a progress object

func DefaultProgress

func DefaultProgress() *Progress

DefaultProgress creates a new progress object

func (*Progress) Add

func (p *Progress) Add(name string, total int64)

Add adds a new bar to the progress

func (*Progress) Current

func (p *Progress) Current(name string, n int64, desc ...string)

func (*Progress) Done

func (p *Progress) Done(name string)

func (*Progress) IOBar

func (p *Progress) IOBar(name string, reader io.Reader, total int64)

func (*Progress) Increment

func (p *Progress) Increment(name string, n int64)

func (*Progress) Next

func (p *Progress) Next(name string)

func (*Progress) SetTotal

func (p *Progress) SetTotal(name string, n int64)

func (*Progress) TrackProgress

func (p *Progress) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser)

func (*Progress) Wait

func (p *Progress) Wait(name string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL