tools

package
v0.0.0-...-811c986 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoNil              = errors.New("unexpected nil value")
	ErrInvalidType        = errors.New("invalid type")
	ErrExpectedStruct     = errors.New("expected struct type")
	ErrNotHandledType     = errors.New("type not handled")
	ErrUnhandledFieldType = errors.New("only handles slice of byte as field type")
)
View Source
var (
	ErrInvalidRepositoryURL = errors.New("invalid given url")
)

Functions

func AskForHostCredentials

func AskForHostCredentials(host Host) error

Takes a host and get its credentials from the user. To define how the credentials must be asked, use the struct tags parse-name, parse-info and parse-reg:

  • parse-name is the name of value that will asked, typically the user will be asked a question like "please enter your <parse-name>" parse-name is required
  • parse-info is just a sentence adding more info to your request
  • parse-reg is the regexp that the user input must match to be valid

func AskYesNo

func AskYesNo(s string) (bool, error)

func CheckError

func CheckError(err error)

func GetLine

func GetLine(params GetLineParams) (ret []byte, err error)

func LoadHostCredentials

func LoadHostCredentials(host Host) error

func RepoInfoFromURL

func RepoInfoFromURL(urlString string) (result struct {
	Owner string
	Repo  string
}, err error)

func Request

func Request(params *RequestParams) (int, error)

Request is just a helper function for the hosts to request their server

func SaveHostCredentials

func SaveHostCredentials(host Host) error

Types

type GetLineParams

type GetLineParams struct {
	Question []byte
	Regexp   *regexp.Regexp
}

type Host

type Host interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	Name() string
}

type RequestParams

type RequestParams struct {
	URL     string
	Method  string
	Body    interface{}
	Headers map[string]string
	Result  interface{}
}

Jump to

Keyboard shortcuts

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