module

package
v0.0.0-...-5972462 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEditor = "vim"

DefaultEditor is vim because we're adults ;)

View Source
const GithubAPI = "https://api.github.com"

GithubAPI github api url

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty(input string) bool

IsEmpty if field is empty

func NotEmpty

func NotEmpty(input string) error

NotEmpty returns error if input is empty

func Optional

func Optional(_ string) error

Optional optional value

Types

type Caller

type Caller struct {
	HTTPClient *HTTPClient
}

Caller struct

func NewCaller

func NewCaller(httpClient *HTTPClient) Caller

NewCaller creates an instance of a caller

func (*Caller) Call

func (c *Caller) Call(endpointID string, service *model.Service, fields map[string]Field) (*http.Response, error)

Call calls the remote service

func (*Caller) GetFields

func (c *Caller) GetFields(endpointID string, service *model.Service) map[string]Field

GetFields get fields to collect from end user

func (*Caller) MergeFields

func (c *Caller) MergeFields(m1, m2 map[string]Field) map[string]Field

MergeFields merges two fields list

func (*Caller) ParseFields

func (c *Caller) ParseFields(data string) map[string]Field

ParseFields parses a string to fetch fields

func (*Caller) Pretty

func (c *Caller) Pretty(response *http.Response) string

Pretty returns colored output

func (*Caller) ReplaceVars

func (c *Caller) ReplaceVars(data string, fields map[string]Field) string

ReplaceVars replaces vars

type Editor

type Editor struct{}

Editor type

func (*Editor) Edit

func (e *Editor) Edit(path string) error

Edit opens path in a text editor.

type Field

type Field struct {
	Prompt     string
	IsOptional bool
	Default    string
	Value      string
}

Field struct

type File

type File struct {
	Content  string `json:"content"`
	Filename string `json:"filename"`
}

File struct

type FileSystem

type FileSystem struct {
	Files map[string]VFile
}

FileSystem struct

func NewFileSystem

func NewFileSystem() *FileSystem

NewFileSystem creates a file system object

func (*FileSystem) ConvertToJSON

func (f *FileSystem) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*FileSystem) DumpLocally

func (f *FileSystem) DumpLocally(basePath string) error

DumpLocally updates a local path

func (*FileSystem) LoadFromJSON

func (f *FileSystem) LoadFromJSON(data []byte) (bool, error)

LoadFromJSON update object from json

func (*FileSystem) LoadFromLocal

func (f *FileSystem) LoadFromLocal(basePath string, extension string) error

LoadFromLocal gets files from a local path

func (*FileSystem) Sync

func (f *FileSystem) Sync(remoteFs *FileSystem) error

Sync update fs object from remote fs

type FuzzyFinder

type FuzzyFinder struct{}

FuzzyFinder type

func (*FuzzyFinder) Available

func (f *FuzzyFinder) Available() bool

Available validates if fzf installed

func (*FuzzyFinder) Show

func (f *FuzzyFinder) Show(items []string) (string, error)

Show show a fzf list

type Gist

type Gist struct {
	Description string          `json:"description"`
	Public      bool            `json:"public"`
	Files       map[string]File `json:"files"`
}

Gist struct

func (*Gist) ConvertToJSON

func (g *Gist) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*Gist) LoadFromJSON

func (g *Gist) LoadFromJSON(data []byte) (bool, error)

LoadFromJSON update object from json

type GistResponse

type GistResponse struct {
	ID          string          `json:"id"`
	Description string          `json:"description"`
	CreatedAt   string          `json:"created_at"`
	CreatedTime int64           `json:"created_at_timestamp"`
	UpdatedAt   string          `json:"updated_at"`
	UpdatedTime int64           `json:"updated_at_timestamp"`
	Public      bool            `json:"public"`
	Files       map[string]File `json:"files"`
}

GistResponse struct

func (*GistResponse) ConvertToJSON

func (g *GistResponse) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*GistResponse) LoadFromJSON

func (g *GistResponse) LoadFromJSON(data []byte) (bool, error)

LoadFromJSON update object from json

type Github

type Github struct {
	OAuth      OAuth
	HTTPClient *HTTPClient
	APIURL     string
}

Github struct

func NewGithubClient

func NewGithubClient(httpClient *HTTPClient, apiURL, username, token string) Github

NewGithubClient creates an instance of github client

func (*Github) Check

func (g *Github) Check(ctx context.Context) (OAuth, error)

Check fetch current OAuth token data

func (*Github) CreateGist

func (g *Github) CreateGist(ctx context.Context, gist Gist) (GistResponse, error)

CreateGist creates a gist

func (*Github) DeleteGist

func (g *Github) DeleteGist(ctx context.Context, id string) (bool, error)

DeleteGist deletes a gist

func (*Github) GetGist

func (g *Github) GetGist(ctx context.Context, id string) (GistResponse, error)

GetGist gets a gist

func (*Github) UpdateGist

func (g *Github) UpdateGist(ctx context.Context, id string, gist Gist) (GistResponse, error)

UpdateGist updates a gist

type HTTPClient

type HTTPClient struct {
	Timeout time.Duration
}

HTTPClient struct

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient creates an instance of http client

func (*HTTPClient) BuildData

func (h *HTTPClient) BuildData(parameters map[string]string) string

BuildData build body data

func (*HTTPClient) BuildParameters

func (h *HTTPClient) BuildParameters(endpoint string, parameters map[string]string) (string, error)

BuildParameters add parameters to URL

func (*HTTPClient) Delete

func (h *HTTPClient) Delete(ctx context.Context, endpoint string, parameters, headers map[string]string) (*http.Response, error)

Delete http call

func (*HTTPClient) Get

func (h *HTTPClient) Get(ctx context.Context, endpoint string, parameters, headers map[string]string) (*http.Response, error)

Get http call

func (*HTTPClient) GetHeaderValue

func (h *HTTPClient) GetHeaderValue(response *http.Response, key string) string

GetHeaderValue get response header value

func (*HTTPClient) GetStatusCode

func (h *HTTPClient) GetStatusCode(response *http.Response) int

GetStatusCode response status code

func (*HTTPClient) Patch

func (h *HTTPClient) Patch(ctx context.Context, endpoint string, data string, parameters, headers map[string]string) (*http.Response, error)

Patch http call

func (*HTTPClient) Post

func (h *HTTPClient) Post(ctx context.Context, endpoint string, data string, parameters, headers map[string]string) (*http.Response, error)

Post http call

func (*HTTPClient) Put

func (h *HTTPClient) Put(ctx context.Context, endpoint string, data string, parameters, headers map[string]string) (*http.Response, error)

Put http call

func (*HTTPClient) ToString

func (h *HTTPClient) ToString(response *http.Response) (string, error)

ToString response body to string

type OAuth

type OAuth struct {
	Token    string
	Username string
	Scopes   string
	Valid    bool
}

OAuth struct

type Prompt

type Prompt struct {
}

Prompt struct

func (*Prompt) Input

func (p *Prompt) Input(label string, validate promptui.ValidateFunc) (string, error)

Input request a value from end user

func (*Prompt) Select

func (p *Prompt) Select(label string, items []string) (string, error)

Select request a value from a list from end user

type VFile

type VFile struct {
	ModTimestamp int64
	Content      string
	Name         string
}

VFile struct

Jump to

Keyboard shortcuts

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