diff --git a/cointop/cmd/cmd.go b/cointop/cmd/cmd.go index c01f93c..339cda3 100644 --- a/cointop/cmd/cmd.go +++ b/cointop/cmd/cmd.go @@ -16,6 +16,7 @@ func Execute() { var refreshRate uint var config, cmcAPIKey, apiChoice, colorscheme, coin, currency string cacheDir := filecache.DefaultCacheDir + perPage := cointop.DefaultPerPage rootCmd := &cobra.Command{ Use: "cointop", @@ -78,6 +79,7 @@ For more information, visit: https://github.com/miguelmota/cointop`, HideStatusbar: hideStatusbar, OnlyTable: onlyTable, RefreshRate: refreshRateP, + PerPage: perPage, }) if err != nil { return err @@ -98,6 +100,7 @@ For more information, visit: https://github.com/miguelmota/cointop`, rootCmd.Flags().BoolVarP(&silent, "silent", "s", false, "Silence log ouput") rootCmd.Flags().BoolVarP(&noCache, "no-cache", "", false, "No cache") rootCmd.Flags().UintVarP(&refreshRate, "refresh-rate", "r", 60, "Refresh rate in seconds. Set to 0 to not auto-refresh") + rootCmd.Flags().UintVarP(&perPage, "per-page", "", perPage, "Per page") rootCmd.Flags().StringVarP(&config, "config", "c", "", fmt.Sprintf("Config filepath. (default %s)", cointop.DefaultConfigFilepath)) rootCmd.Flags().StringVarP(&cmcAPIKey, "coinmarketcap-api-key", "", "", "Set the CoinMarketCap API key") rootCmd.Flags().StringVarP(&apiChoice, "api", "", cointop.CoinGecko, "API choice. Available choices are \"coinmarketcap\" and \"coingecko\"") diff --git a/cointop/cointop.go b/cointop/cointop.go index 313527f..c6b0d81 100644 --- a/cointop/cointop.go +++ b/cointop/cointop.go @@ -134,6 +134,7 @@ type Config struct { NoCache bool OnlyTable bool RefreshRate *uint + PerPage uint } // APIKeys is api keys structure @@ -141,6 +142,9 @@ type APIKeys struct { cmc string } +// DefaultPerPage ... +var DefaultPerPage uint = 100 + // DefaultColorscheme ... var DefaultColorscheme = "cointop" @@ -170,6 +174,11 @@ func NewCointop(config *Config) (*Cointop, error) { }) } + perPage := DefaultPerPage + if config.PerPage != 0 { + perPage = config.PerPage + } + ct := &Cointop{ apiChoice: CoinGecko, apiKeys: new(APIKeys), @@ -198,7 +207,7 @@ func NewCointop(config *Config) (*Cointop, error) { shortcutKeys: DefaultShortcuts(), sortBy: "rank", page: 0, - perPage: 100, + perPage: int(perPage), portfolio: &Portfolio{ Entries: make(map[string]*PortfolioEntry, 0), },