jenkins-cli: github.com/jenkins-zh/jenkins-cli/util Index | Files

package util

import "github.com/jenkins-zh/jenkins-cli/util"

Index

Package Files

cmd.go collect.go http.go logger.go padding.go password.go reflect.go table.go

Constants

const (
    // ContentType is for the http header of content type
    ContentType = "Content-Type"
    // ApplicationForm is for the form submit
    ApplicationForm = "application/x-www-form-urlencoded"
)
const (
    // AlignLeft align left
    AlignLeft = 0
    // AlignCenter align center
    AlignCenter = 1
    // AlignRight align right
    AlignRight = 2
)

func Exec Uses

func Exec(argv0 string, argv []string, envv []string, systemCallExec SystemCallExec) error

Exec is the wrapper of syscall.Exec

func ExecCommand Uses

func ExecCommand(context ExecContext, name string, arg ...string) *exec.Cmd

ExecCommand is a warp of exec.Command

func FakeExecCommandSuccess Uses

func FakeExecCommandSuccess(command string, args ...string) *exec.Cmd

FakeExecCommandSuccess is a function that initialises a new exec.Cmd, one which will simply call TestShellProcessSuccess rather than the command it is provided. It will also pass through the command and its arguments as an argument to TestShellProcessSuccess

func FakeLookPath Uses

func FakeLookPath(path string) (string, error)

FakeLookPath is a fake function of exec.LookPath

func FakeSystemCallExecSuccess Uses

func FakeSystemCallExecSuccess(argv0 string, argv []string, envv []string) (err error)

FakeSystemCallExecSuccess is a fake function of syscall.Exec

func GeneratePassword Uses

func GeneratePassword(length int) string

GeneratePassword generates a password with the specific length

func InitLogger Uses

func InitLogger(level string) (logger *zap.Logger, err error)

InitLogger returns a logger

func Lenf Uses

func Lenf(han string) (l int)

Lenf counts the number

func LookPath Uses

func LookPath(file string, context LookPathContext) (string, error)

LookPath is the wrapper of exec.LookPath

func MaxAndMin Uses

func MaxAndMin(data []float64) (max, min float64)

MaxAndMin return the max and min number

func Open Uses

func Open(url string, browser string, cmdContext ExecContext) error

Open a URL in a browser

func Pad Uses

func Pad(s, pad string, width int, align int) string

Pad give a pad

func PadCenter Uses

func PadCenter(s, pad string, width int) string

PadCenter pad as center

func PadLeft Uses

func PadLeft(s, pad string, width int) string

PadLeft pad as left

func PadRight Uses

func PadRight(s, pad string, width int) string

PadRight pas as right

func PrintCollectTrend Uses

func PrintCollectTrend(data []float64) (buf string)

PrintCollectTrend print the trend of data

func ReflectFieldValueAsString Uses

func ReflectFieldValueAsString(v reflect.Value, field string) string

ReflectFieldValueAsString returns the value of a field

func SetProxy Uses

func SetProxy(proxy, proxyAuth string, tr *http.Transport) (err error)

SetProxy set the proxy for a http

type ExecContext Uses

type ExecContext = func(name string, arg ...string) *exec.Cmd

ExecContext is the context of system command caller

type HTTPDownloader Uses

type HTTPDownloader struct {
    TargetFilePath     string
    URL                string
    ShowProgress       bool
    InsecureSkipVerify bool

    UserName string
    Password string

    Proxy     string
    ProxyAuth string

    Debug        bool
    RoundTripper http.RoundTripper
}

HTTPDownloader is the downloader for http request

func (*HTTPDownloader) DownloadFile Uses

func (h *HTTPDownloader) DownloadFile() error

DownloadFile download a file with the progress

type LookPathContext Uses

type LookPathContext = func(file string) (string, error)

LookPathContext is the context of look path

type ProgressIndicator Uses

type ProgressIndicator struct {
    Writer io.Writer
    Reader io.Reader
    Title  string

    // bytes.Buffer
    Total float64
    // contains filtered or unexported fields
}

ProgressIndicator hold the progress of io operation

func (*ProgressIndicator) Init Uses

func (i *ProgressIndicator) Init()

Init set the default value for progress indicator

func (*ProgressIndicator) Read Uses

func (i *ProgressIndicator) Read(p []byte) (n int, err error)

Read reads the progress

func (*ProgressIndicator) Write Uses

func (i *ProgressIndicator) Write(p []byte) (n int, err error)

Write writes the progress

type SystemCallExec Uses

type SystemCallExec = func(argv0 string, argv []string, envv []string) (err error)

SystemCallExec is the context of syscall.Exec

type Table Uses

type Table struct {
    Out          io.Writer
    Rows         [][]string
    ColumnWidths []int
    ColumnAlign  []int
    Separator    string

    WithHeader bool
}

Table for console print

func CreateTable Uses

func CreateTable(out io.Writer) Table

CreateTable init a table object

func CreateTableWithHeader Uses

func CreateTableWithHeader(out io.Writer, withoutHeader bool) (table Table)

CreateTableWithHeader init a table object

func (*Table) AddHeader Uses

func (t *Table) AddHeader(col ...string)

AddHeader adds a header to the table

func (*Table) AddRow Uses

func (t *Table) AddRow(col ...string)

AddRow adds a new row to the table

func (*Table) Clear Uses

func (t *Table) Clear()

Clear removes all rows while preserving the layout

func (*Table) GetColumnAlign Uses

func (t *Table) GetColumnAlign(i int) int

GetColumnAlign return the column alignment

func (*Table) Render Uses

func (t *Table) Render()

Render render the table into byte array

func (*Table) SetColumnAlign Uses

func (t *Table) SetColumnAlign(i int, align int)

SetColumnAlign sets the column alignment for the given column index

func (*Table) SetColumnsAligns Uses

func (t *Table) SetColumnsAligns(colAligns []int)

SetColumnsAligns sets the alignment of the columns

Package util imports 23 packages (graph) and is imported by 5 packages. Updated 2020-08-04. Refresh now. Tools for package owners.