|
|
@ -56,6 +56,7 @@ type State struct {
|
|
|
|
keepRowFocusOnSort bool
|
|
|
|
keepRowFocusOnSort bool
|
|
|
|
lastSelectedRowIndex int
|
|
|
|
lastSelectedRowIndex int
|
|
|
|
marketBarHeight int
|
|
|
|
marketBarHeight int
|
|
|
|
|
|
|
|
maxPages int
|
|
|
|
page int
|
|
|
|
page int
|
|
|
|
perPage int
|
|
|
|
perPage int
|
|
|
|
portfolio *Portfolio
|
|
|
|
portfolio *Portfolio
|
|
|
@ -154,6 +155,7 @@ type Config struct {
|
|
|
|
OnlyTable bool
|
|
|
|
OnlyTable bool
|
|
|
|
RefreshRate *uint
|
|
|
|
RefreshRate *uint
|
|
|
|
PerPage uint
|
|
|
|
PerPage uint
|
|
|
|
|
|
|
|
MaxPages uint
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// APIKeys is api keys structure
|
|
|
|
// APIKeys is api keys structure
|
|
|
@ -161,9 +163,21 @@ type APIKeys struct {
|
|
|
|
cmc string
|
|
|
|
cmc string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultCurrency ...
|
|
|
|
|
|
|
|
var DefaultCurrency = "USD"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultChartRange ...
|
|
|
|
|
|
|
|
var DefaultChartRange = "1Y"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultSortBy ...
|
|
|
|
|
|
|
|
var DefaultSortBy = "rank"
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultPerPage ...
|
|
|
|
// DefaultPerPage ...
|
|
|
|
var DefaultPerPage uint = 100
|
|
|
|
var DefaultPerPage uint = 100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MaxPages
|
|
|
|
|
|
|
|
var DefaultMaxPages uint = 35
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultColorscheme ...
|
|
|
|
// DefaultColorscheme ...
|
|
|
|
var DefaultColorscheme = "cointop"
|
|
|
|
var DefaultColorscheme = "cointop"
|
|
|
|
|
|
|
|
|
|
|
@ -193,10 +207,15 @@ func NewCointop(config *Config) (*Cointop, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
perPage := DefaultPerPage
|
|
|
|
perPage := DefaultPerPage
|
|
|
|
if config.PerPage != 0 {
|
|
|
|
if config.PerPage > 0 {
|
|
|
|
perPage = config.PerPage
|
|
|
|
perPage = config.PerPage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxPages := DefaultMaxPages
|
|
|
|
|
|
|
|
if config.MaxPages > 0 {
|
|
|
|
|
|
|
|
maxPages = config.MaxPages
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ct := &Cointop{
|
|
|
|
ct := &Cointop{
|
|
|
|
// defaults
|
|
|
|
// defaults
|
|
|
|
apiChoice: CoinGecko,
|
|
|
|
apiChoice: CoinGecko,
|
|
|
@ -210,13 +229,13 @@ func NewCointop(config *Config) (*Cointop, error) {
|
|
|
|
chartRanges: ChartRanges(),
|
|
|
|
chartRanges: ChartRanges(),
|
|
|
|
debug: debug,
|
|
|
|
debug: debug,
|
|
|
|
chartRangesMap: ChartRangesMap(),
|
|
|
|
chartRangesMap: ChartRangesMap(),
|
|
|
|
limiter: time.Tick(2 * time.Second),
|
|
|
|
limiter: time.NewTicker(2 * time.Second).C,
|
|
|
|
filecache: nil,
|
|
|
|
filecache: nil,
|
|
|
|
State: &State{
|
|
|
|
State: &State{
|
|
|
|
allCoins: []*Coin{},
|
|
|
|
allCoins: []*Coin{},
|
|
|
|
cacheDir: DefaultCacheDir,
|
|
|
|
cacheDir: DefaultCacheDir,
|
|
|
|
coinsTableColumns: DefaultCoinTableHeaders,
|
|
|
|
coinsTableColumns: DefaultCoinTableHeaders,
|
|
|
|
currencyConversion: "USD",
|
|
|
|
currencyConversion: DefaultCurrency,
|
|
|
|
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
|
|
|
|
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
|
|
|
|
favoritesBySymbol: make(map[string]bool),
|
|
|
|
favoritesBySymbol: make(map[string]bool),
|
|
|
|
favorites: make(map[string]bool),
|
|
|
|
favorites: make(map[string]bool),
|
|
|
@ -226,11 +245,12 @@ func NewCointop(config *Config) (*Cointop, error) {
|
|
|
|
hideStatusbar: config.HideStatusbar,
|
|
|
|
hideStatusbar: config.HideStatusbar,
|
|
|
|
keepRowFocusOnSort: false,
|
|
|
|
keepRowFocusOnSort: false,
|
|
|
|
marketBarHeight: 1,
|
|
|
|
marketBarHeight: 1,
|
|
|
|
|
|
|
|
maxPages: int(maxPages),
|
|
|
|
onlyTable: config.OnlyTable,
|
|
|
|
onlyTable: config.OnlyTable,
|
|
|
|
refreshRate: 60 * time.Second,
|
|
|
|
refreshRate: 60 * time.Second,
|
|
|
|
selectedChartRange: "1Y",
|
|
|
|
selectedChartRange: DefaultChartRange,
|
|
|
|
shortcutKeys: DefaultShortcuts(),
|
|
|
|
shortcutKeys: DefaultShortcuts(),
|
|
|
|
sortBy: "rank",
|
|
|
|
sortBy: DefaultSortBy,
|
|
|
|
page: 0,
|
|
|
|
page: 0,
|
|
|
|
perPage: int(perPage),
|
|
|
|
perPage: int(perPage),
|
|
|
|
portfolio: &Portfolio{
|
|
|
|
portfolio: &Portfolio{
|
|
|
@ -346,7 +366,7 @@ func NewCointop(config *Config) (*Cointop, error) {
|
|
|
|
if ct.apiChoice == CoinMarketCap {
|
|
|
|
if ct.apiChoice == CoinMarketCap {
|
|
|
|
ct.api = api.NewCMC(ct.apiKeys.cmc)
|
|
|
|
ct.api = api.NewCMC(ct.apiKeys.cmc)
|
|
|
|
} else if ct.apiChoice == CoinGecko {
|
|
|
|
} else if ct.apiChoice == CoinGecko {
|
|
|
|
ct.api = api.NewCG()
|
|
|
|
ct.api = api.NewCG(perPage, maxPages)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return nil, ErrInvalidAPIChoice
|
|
|
|
return nil, ErrInvalidAPIChoice
|
|
|
|
}
|
|
|
|
}
|
|
|
|