cointop

package
v0.0.0-...-e7512e9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoinGecko = "coingecko"

CoinGecko is API choice

View Source
var CoinMarketCap = "coinmarketcap"

CoinMarketCap is API choice

View Source
var DefaultColors = `` /* 1611-byte string literal not displayed */

DefaultColors is the default color scheme

View Source
var ErrInvalidAPIChoice = errors.New("Invalid API choice")

ErrInvalidAPIChoice is error for invalid API choice

Functions

func ActionsMap

func ActionsMap() map[string]bool

ActionsMap returns a map of all the available actions

func Clean

func Clean() error

Clean ...

func DefaultShortcuts

func DefaultShortcuts() map[string]string

DefaultShortcuts is a map of the default shortcuts

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

GetBytes returns the interface in bytes form

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes and extends the path string

func PrintPrice

func PrintPrice(config *PriceConfig) error

PrintPrice outputs the current price of the coin

func PrintVersion

func PrintVersion()

PrintVersion prints the version

func Reset

func Reset() error

Reset ...

func Slugify

func Slugify(s string) string

Slugify returns a slugified string

func TableColumnOrder

func TableColumnOrder() []string

TableColumnOrder returns the default order of the table columns

func UserPreferredHomeDir

func UserPreferredHomeDir() string

UserPreferredHomeDir returns the preferred home directory for the user

func Version

func Version() string

Version returns cointop version

Types

type APIKeys

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

APIKeys is api keys structure

type ChartView

type ChartView struct {
	*View
}

ChartView is structure for chart view

func NewChartView

func NewChartView() *ChartView

NewChartView returns a new chart view

type Coin

type Coin struct {
	ID               string
	Name             string
	Slug             string
	Symbol           string
	Rank             int
	Price            float64
	Volume24H        float64
	MarketCap        float64
	AvailableSupply  float64
	TotalSupply      float64
	PercentChange1H  float64
	PercentChange24H float64
	PercentChange7D  float64
	PercentChange30D float64
	PercentChange1Y  float64
	LastUpdated      string
	// for favorites
	Favorite bool
	// for portfolio
	Holdings float64
	Balance  float64
}

Coin is the row structure

type Cointop

type Cointop struct {
	ActionsMap map[string]bool

	State *State

	TableColumnOrder []string
	Views            *Views
	// contains filtered or unexported fields
}

Cointop cointop

func NewCointop

func NewCointop(config *Config) (*Cointop, error)

NewCointop initializes cointop

func (*Cointop) ActionExists

func (ct *Cointop) ActionExists(action string) bool

ActionExists returns true if action exists

func (*Cointop) ActiveViewName

func (ct *Cointop) ActiveViewName() string

ActiveViewName returns the name of the active view

func (*Cointop) AllCoins

func (ct *Cointop) AllCoins() []*Coin

AllCoins returns a slice of all the coins

func (*Cointop) CacheAllCoinsSlugMap

func (ct *Cointop) CacheAllCoinsSlugMap()

CacheAllCoinsSlugMap writes the coins map to the memory and disk cache

func (*Cointop) CacheKey

func (ct *Cointop) CacheKey(key string) string

CacheKey returns cached value given key

func (*Cointop) ChartPoints

func (ct *Cointop) ChartPoints(symbol string, name string) error

ChartPoints calculates the the chart points

func (*Cointop) ClampedWidth

func (ct *Cointop) ClampedWidth() int

ClampedWidth returns the clamped width

func (*Cointop) CoinBySymbol

func (ct *Cointop) CoinBySymbol(symbol string) *Coin

CoinBySymbol returns the coin struct given the symbol

func (*Cointop) CursorDownOrNextPage

func (ct *Cointop) CursorDownOrNextPage() error

CursorDownOrNextPage ...

func (*Cointop) CursorUpOrPreviousPage

func (ct *Cointop) CursorUpOrPreviousPage() error

CursorUpOrPreviousPage ...

func (*Cointop) EnlargeChart

func (ct *Cointop) EnlargeChart() error

EnlargeChart increases the chart height by one row

func (*Cointop) Exit

func (ct *Cointop) Exit()

Exit safely exits the program

func (*Cointop) FirstChartRange

func (ct *Cointop) FirstChartRange() error

FirstChartRange sets the chart to the first range option

func (*Cointop) GetTableCoinsSlice

func (ct *Cointop) GetTableCoinsSlice() []*Coin

GetTableCoinsSlice returns a slice of the table rows

func (*Cointop) HighlightedPageRowIndex

func (ct *Cointop) HighlightedPageRowIndex() int

HighlightedPageRowIndex returns the index of page row of the highlighted row

func (*Cointop) HighlightedRowCoin

func (ct *Cointop) HighlightedRowCoin() *Coin

HighlightedRowCoin returns the coin at the index of the highlighted row

func (*Cointop) HighlightedRowIndex

func (ct *Cointop) HighlightedRowIndex() int

HighlightedRowIndex returns the index of the highlighted row

func (*Cointop) LastChartRange

func (ct *Cointop) LastChartRange() error

LastChartRange sets the chart to the last range option

func (*Cointop) NextChartRange

func (ct *Cointop) NextChartRange() error

NextChartRange sets the chart to the next range option

func (ct *Cointop) OpenLink() error

OpenLink opens the url in a browser

func (*Cointop) PortfolioChart

func (ct *Cointop) PortfolioChart() error

PortfolioChart renders the portfolio chart

func (*Cointop) PortfolioEntry

func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool)

PortfolioEntry returns a portfolio entry

func (*Cointop) PortfolioEntryExists

func (ct *Cointop) PortfolioEntryExists(c *Coin) bool

PortfolioEntryExists returns true if portfolio entry exists

func (*Cointop) PrevChartRange

func (ct *Cointop) PrevChartRange() error

PrevChartRange sets the chart to the prevous range option

func (*Cointop) Quit

func (ct *Cointop) Quit() error

Quit quites the program

func (*Cointop) QuitView

func (ct *Cointop) QuitView() error

QuitView exists the current view

func (*Cointop) ReadAPIKeyFromStdin

func (ct *Cointop) ReadAPIKeyFromStdin(name string) (string, error)

ReadAPIKeyFromStdin reads the user inputed API from the stdin prompt

func (ct *Cointop) RefreshRowLink() error

RefreshRowLink updates the row link in the statusbar

func (*Cointop) RefreshTable

func (ct *Cointop) RefreshTable() error

RefreshTable refreshes the table

func (*Cointop) RowChanged

func (ct *Cointop) RowChanged()

RowChanged is called when the row is updated

func (ct *Cointop) RowLink() string

RowLink returns the row url link

func (*Cointop) RowLinkShort

func (ct *Cointop) RowLinkShort() string

RowLinkShort returns a shortened version of the row url link

func (*Cointop) Run

func (ct *Cointop) Run() error

Run runs cointop

func (*Cointop) Save

func (ct *Cointop) Save() error

Save saves the cointop settings to the config file

func (*Cointop) SetActiveView

func (ct *Cointop) SetActiveView(v string) error

SetActiveView sets the active view

func (*Cointop) SetSavingStatus

func (ct *Cointop) SetSavingStatus()

SetSavingStatus sets the saving indicator in the statusbar

func (*Cointop) SetViewOnBottom

func (ct *Cointop) SetViewOnBottom(v string) error

SetViewOnBottom sets the view to the bottom layer

func (*Cointop) ShortenChart

func (ct *Cointop) ShortenChart() error

ShortenChart decreases the chart height by one row

func (*Cointop) ShowChartLoader

func (ct *Cointop) ShowChartLoader() error

ShowChartLoader shows chart loading indicator

func (*Cointop) ToggleCoinChart

func (ct *Cointop) ToggleCoinChart() error

ToggleCoinChart toggles between the global chart and the coin chart

func (*Cointop) ToggleTableFullscreen

func (ct *Cointop) ToggleTableFullscreen() error

ToggleTableFullscreen toggles the table fullscreen mode

func (*Cointop) Update

func (ct *Cointop) Update(f func() error)

Update takes a callback which updates the view

func (*Cointop) UpdateChart

func (ct *Cointop) UpdateChart() error

UpdateChart updates the chart view

func (*Cointop) UpdateStatusbar

func (ct *Cointop) UpdateStatusbar(s string) error

UpdateStatusbar updates the statusbar view

func (*Cointop) UpdateTable

func (ct *Cointop) UpdateTable() error

UpdateTable updates the table

func (*Cointop) UpdateTableHeader

func (ct *Cointop) UpdateTableHeader()

UpdateTableHeader renders the table header

func (*Cointop) Version

func (ct *Cointop) Version() string

Version returns the cointop version

type Colorscheme

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

Colorscheme is the struct for colorscheme

func NewColorscheme

func NewColorscheme(colors colorschemeColors) *Colorscheme

NewColorscheme ...

func (*Colorscheme) BaseBg

func (c *Colorscheme) BaseBg() gocui.Attribute

BaseBg ...

func (*Colorscheme) BaseFg

func (c *Colorscheme) BaseFg() gocui.Attribute

BaseFg ...

func (*Colorscheme) Chart

func (c *Colorscheme) Chart(a ...interface{}) string

Chart ...

func (*Colorscheme) MarketBarLabelActive

func (c *Colorscheme) MarketBarLabelActive(a ...interface{}) string

MarketBarLabelActive ...

func (*Colorscheme) Marketbar

func (c *Colorscheme) Marketbar(a ...interface{}) string

Marketbar ...

func (*Colorscheme) MarketbarChangeDownSprintf

func (c *Colorscheme) MarketbarChangeDownSprintf() ISprintf

MarketbarChangeDownSprintf ...

func (*Colorscheme) MarketbarChangeSprintf

func (c *Colorscheme) MarketbarChangeSprintf() ISprintf

MarketbarChangeSprintf ...

func (*Colorscheme) MarketbarChangeUpSprintf

func (c *Colorscheme) MarketbarChangeUpSprintf() ISprintf

MarketbarChangeUpSprintf ...

func (*Colorscheme) MarketbarSprintf

func (c *Colorscheme) MarketbarSprintf() ISprintf

MarketbarSprintf ...

func (*Colorscheme) Menu

func (c *Colorscheme) Menu(a ...interface{}) string

Menu ...

func (*Colorscheme) MenuHeader

func (c *Colorscheme) MenuHeader(a ...interface{}) string

MenuHeader ...

func (*Colorscheme) MenuLabel

func (c *Colorscheme) MenuLabel(a ...interface{}) string

MenuLabel ...

func (*Colorscheme) MenuLabelActive

func (c *Colorscheme) MenuLabelActive(a ...interface{}) string

MenuLabelActive ...

func (*Colorscheme) Searchbar

func (c *Colorscheme) Searchbar(a ...interface{}) string

Searchbar ...

func (*Colorscheme) SetViewActiveColor

func (c *Colorscheme) SetViewActiveColor(view *gocui.View, name string)

SetViewActiveColor ...

func (*Colorscheme) SetViewColor

func (c *Colorscheme) SetViewColor(view *gocui.View, name string)

SetViewColor ...

func (*Colorscheme) Statusbar

func (c *Colorscheme) Statusbar(a ...interface{}) string

Statusbar ...

func (*Colorscheme) TableColumnChange

func (c *Colorscheme) TableColumnChange(a ...interface{}) string

TableColumnChange ...

func (*Colorscheme) TableColumnChangeDown

func (c *Colorscheme) TableColumnChangeDown(a ...interface{}) string

TableColumnChangeDown ...

func (*Colorscheme) TableColumnChangeDownSprintf

func (c *Colorscheme) TableColumnChangeDownSprintf() ISprintf

TableColumnChangeDownSprintf ...

func (*Colorscheme) TableColumnChangeSprintf

func (c *Colorscheme) TableColumnChangeSprintf() ISprintf

TableColumnChangeSprintf ...

func (*Colorscheme) TableColumnChangeUp

func (c *Colorscheme) TableColumnChangeUp(a ...interface{}) string

TableColumnChangeUp ...

func (*Colorscheme) TableColumnChangeUpSprintf

func (c *Colorscheme) TableColumnChangeUpSprintf() ISprintf

TableColumnChangeUpSprintf ...

func (*Colorscheme) TableColumnPrice

func (c *Colorscheme) TableColumnPrice(a ...interface{}) string

TableColumnPrice ...

func (*Colorscheme) TableColumnPriceSprintf

func (c *Colorscheme) TableColumnPriceSprintf() ISprintf

TableColumnPriceSprintf ...

func (*Colorscheme) TableHeader

func (c *Colorscheme) TableHeader(a ...interface{}) string

TableHeader ...

func (*Colorscheme) TableHeaderColumnActive

func (c *Colorscheme) TableHeaderColumnActive(a ...interface{}) string

TableHeaderColumnActive ...

func (*Colorscheme) TableHeaderColumnActiveSprintf

func (c *Colorscheme) TableHeaderColumnActiveSprintf() ISprintf

TableHeaderColumnActiveSprintf ...

func (*Colorscheme) TableHeaderSprintf

func (c *Colorscheme) TableHeaderSprintf() ISprintf

TableHeaderSprintf ...

func (*Colorscheme) TableRow

func (c *Colorscheme) TableRow(a ...interface{}) string

TableRow ...

func (*Colorscheme) TableRowActive

func (c *Colorscheme) TableRowActive(a ...interface{}) string

TableRowActive ...

func (*Colorscheme) TableRowFavorite

func (c *Colorscheme) TableRowFavorite(a ...interface{}) string

TableRowFavorite ...

func (*Colorscheme) TableRowFavoriteSprintf

func (c *Colorscheme) TableRowFavoriteSprintf() ISprintf

TableRowFavoriteSprintf ...

func (*Colorscheme) TableRowSprintf

func (c *Colorscheme) TableRowSprintf() ISprintf

TableRowSprintf ...

type Config

type Config struct {
	APIChoice           string
	Colorscheme         string
	ConfigFilepath      string
	CoinMarketCapAPIKey string
	NoPrompts           bool
	HideMarketbar       bool
	HideChart           bool
	HideStatusbar       bool
	OnlyTable           bool
	RefreshRate         *uint
}

Config config options

type ConvertMenuView

type ConvertMenuView struct {
	*View
}

ConvertMenuView is structure for convert menu view

func NewConvertMenuView

func NewConvertMenuView() *ConvertMenuView

NewConvertMenuView returns a new convert menu view

type HelpView

type HelpView struct {
	*View
}

HelpView is structure for help view

func NewHelpView

func NewHelpView() *HelpView

NewHelpView returns a new help view

type ISprintf

type ISprintf func(...interface{}) string

ISprintf is a sprintf interface

type IView

type IView interface {
	Backing() *gocui.View
	SetBacking(gocuiView *gocui.View)
	Name() string
}

IView is a cointop view

type InputView

type InputView struct {
	*View
}

InputView is structure for help view

func NewInputView

func NewInputView() *InputView

NewInputView returns a new help view

type MarketbarView

type MarketbarView struct {
	*View
}

MarketbarView is structure for marketbar view

func NewMarketbarView

func NewMarketbarView() *MarketbarView

NewMarketbarView returns a new marketbar view

type Portfolio

type Portfolio struct {
	Entries map[string]*PortfolioEntry
}

Portfolio is portfolio structure

type PortfolioEntry

type PortfolioEntry struct {
	Coin     string
	Holdings float64
}

PortfolioEntry is portfolio entry

type PortfolioUpdateMenuView

type PortfolioUpdateMenuView struct {
	*View
}

PortfolioUpdateMenuView is structure for portfolio update menu view

func NewPortfolioUpdateMenuView

func NewPortfolioUpdateMenuView() *PortfolioUpdateMenuView

NewPortfolioUpdateMenuView returns a new portfolio update menu view

type PriceConfig

type PriceConfig struct {
	Coin      string
	Currency  string
	APIChoice string
}

PriceConfig is the config options for the price command

type SearchFieldView

type SearchFieldView struct {
	*View
}

SearchFieldView is structure for search field view

func NewSearchFieldView

func NewSearchFieldView() *SearchFieldView

NewSearchFieldView returns a new search field view

type State

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

State is the state preferences of cointop

type StatusbarView

type StatusbarView struct {
	*View
}

StatusbarView is structure for statusbar view

func NewStatusbarView

func NewStatusbarView() *StatusbarView

NewStatusbarView returns a new statusbar view

func (*StatusbarView) Update

func (statusbar *StatusbarView) Update(str string) error

Update updates the content of the statusbar

type TableHeaderView

type TableHeaderView struct {
	*View
}

TableHeaderView is structure for table header view

func NewTableHeaderView

func NewTableHeaderView() *TableHeaderView

NewTableHeaderView returns a new table header view

type TableView

type TableView struct {
	*View
}

TableView is structure for table view

func NewTableView

func NewTableView() *TableView

NewTableView returns a new table view

type View

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

View is a cointop view

func NewView

func NewView(name string) *View

NewView creates a new view

func (*View) Backing

func (view *View) Backing() *gocui.View

Backing returns the backing gocui view

func (*View) Height

func (view *View) Height() int

Height returns the view height

func (*View) Name

func (view *View) Name() string

Name returns the view's name

func (*View) SetBacking

func (view *View) SetBacking(gocuiView *gocui.View)

SetBacking sets the backing gocui view

func (*View) Width

func (view *View) Width() int

Width returns the view width

type Views

type Views struct {
	Chart               *ChartView
	Table               *TableView
	TableHeader         *TableHeaderView
	Marketbar           *MarketbarView
	SearchField         *SearchFieldView
	Statusbar           *StatusbarView
	Help                *HelpView
	ConvertMenu         *ConvertMenuView
	Input               *InputView
	PortfolioUpdateMenu *PortfolioUpdateMenuView
}

Views are all views in cointop

Directories

Path Synopsis
api
coingecko/v3
Package coingecko is forked from https://github.com/superoo7/go-gecko
Package coingecko is forked from https://github.com/superoo7/go-gecko
common
api
gizak/termui
Package termui is a library designed for creating command line UI.
Package termui is a library designed for creating command line UI.
pad

Jump to

Keyboard shortcuts

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