helper

package
v0.0.0-...-d2f2feb Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package helper provides handy func and struct to be reused in commands

Package helper provides handy func and struct to be reused in commands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppAutoComplete

func AppAutoComplete(c *cli.Context)

AppAutoComplete extends the default autocomplete provided by urfave/cli by filtering on flags when - or -- is typed

func AutoComplete

func AutoComplete(c *cli.Context, cache *FileCache)

AutoComplete enhance the autocompletion by responding to project / user / username / repository... flags and printing available values from the cache. Everything that get printed by this function could be used as autocompletion value. Space is used as separator.

func PrintLinks(l bitclient.Links)

PrintLinks output the bitclient.Links to stdout in a readable way

Types

type Cache

type Cache interface {
	WriteObject(namespace string, object interface{}) error
	Clear(namespace string) error
}

Cache interface define contract for Cache implementations

type FileCache

type FileCache struct {
	Users        []bitclient.User
	Projects     []bitclient.Project
	Repositories []bitclient.Repository
	// contains filtered or unexported fields
}

FileCache is a Cache implementation storing data in a file

func NewFileCache

func NewFileCache(cacheDir string) *FileCache

NewFileCache create a new FileCache instance

func (*FileCache) Clear

func (c *FileCache) Clear() error

Clear erase cached data both in memory and file

func (*FileCache) FindRepositoriesBySlug

func (c *FileCache) FindRepositoriesBySlug(slug string) []bitclient.Repository

FindRepositoriesBySlug lookup for given repository slug in cached repositories

func (*FileCache) FindRepository

func (c *FileCache) FindRepository(projectKey string, repoSlug string) (bitclient.Repository, error)

FindRepository lookup for a repository from slug and projectKey

func (*FileCache) FindUserByUsername

func (c *FileCache) FindUserByUsername(username string) (bitclient.User, error)

func (*FileCache) Load

func (c *FileCache) Load() error

Load read file data and set them in memory

func (*FileCache) Save

func (c *FileCache) Save() error

Save write the cached data to the file

func (*FileCache) String

func (c *FileCache) String() string

String convert cached data to printable strings

Jump to

Keyboard shortcuts

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