diff --git a/cmd/commands/price.go b/cmd/commands/price.go index a0f6c7ab..4391df49 100644 --- a/cmd/commands/price.go +++ b/cmd/commands/price.go @@ -1,6 +1,8 @@ package cmd import ( + "errors" + "github.com/miguelmota/cointop/cointop" "github.com/spf13/cobra" ) @@ -8,14 +10,21 @@ import ( // PriceCmd ... func PriceCmd() *cobra.Command { var apiChoice string + var coin string var coins []string var currency string priceCmd := &cobra.Command{ Use: "price", - Short: "Displays the current price of a coin", + Short: "Displays the current price of coin(s)", Long: `The price command display the current price of a coin`, RunE: func(cmd *cobra.Command, args []string) error { + if coin != "" { + if len(coins) > 0 { + return errors.New("flags --coin and --coins cannot be used at the same time") + } + coins = append(coins, coin) + } return cointop.PrintPrices(&cointop.PricesConfig{ Coins: coins, Currency: currency, @@ -25,6 +34,7 @@ func PriceCmd() *cobra.Command { } priceCmd.Flags().StringSliceVarP(&coins, "coins", "c", nil, "Name or symbol of coin(s), comma separated. E.g. \"Bitcoin\" Eg. \"btc,eth,doge\"") + priceCmd.Flags().StringVarP(&coin, "coin", "", "", "Name or symbol of coin. Alias for --coins") priceCmd.Flags().StringVarP(¤cy, "currency", "f", "USD", "The currency to convert to") priceCmd.Flags().StringVarP(&apiChoice, "api", "a", cointop.CoinGecko, "API choice. Available choices are \"coinmarketcap\" and \"coingecko\"") diff --git a/cointop/layout.go b/cointop/layout.go index 4970188f..a41c6350 100644 --- a/cointop/layout.go +++ b/cointop/layout.go @@ -48,7 +48,7 @@ func (ct *Cointop) layout() error { ct.Views.Marketbar.SetBacking(nil) } } else { - if err := ct.ui.SetView(ct.Views.Marketbar, 0, topOffset, maxX, marketbarHeight+1); err != nil { + if err := ct.ui.SetView(ct.Views.Marketbar, 0, topOffset-1, maxX, marketbarHeight+1); err != nil { ct.Views.Marketbar.SetFrame(false) ct.Views.Marketbar.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Marketbar.Name())) ct.Views.Marketbar.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.Marketbar.Name())) @@ -73,7 +73,7 @@ func (ct *Cointop) layout() error { ct.Views.Chart.SetBacking(nil) } } else { - if err := ct.ui.SetView(ct.Views.Chart, 0, topOffset, maxX, topOffset+chartHeight); err != nil { + if err := ct.ui.SetView(ct.Views.Chart, 0, topOffset-1, maxX, topOffset+chartHeight); err != nil { ct.Views.Chart.Clear() ct.Views.Chart.SetFrame(false) ct.Views.Chart.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.Chart.Name())) @@ -92,7 +92,7 @@ func (ct *Cointop) layout() error { tableOffsetX := ct.State.tableOffsetX topOffset = topOffset + chartHeight - if err := ct.ui.SetView(ct.Views.TableHeader, tableOffsetX, topOffset, maxX, topOffset+2); err != nil { + if err := ct.ui.SetView(ct.Views.TableHeader, tableOffsetX, topOffset-1, maxX, topOffset+1); err != nil { ct.Views.TableHeader.SetFrame(false) ct.Views.TableHeader.SetFgColor(ct.colorscheme.gocuiFgColor(ct.Views.TableHeader.Name())) ct.Views.TableHeader.SetBgColor(ct.colorscheme.gocuiBgColor(ct.Views.TableHeader.Name())) @@ -100,7 +100,7 @@ func (ct *Cointop) layout() error { } topOffset = topOffset + headerHeight - if err := ct.ui.SetView(ct.Views.Table, tableOffsetX, topOffset, maxX, maxY-statusbarHeight); err != nil { + if err := ct.ui.SetView(ct.Views.Table, tableOffsetX, topOffset-1, maxX, maxY-statusbarHeight); err != nil { ct.Views.Table.SetFrame(false) ct.Views.Table.SetHighlight(true) ct.Views.Table.SetSelFgColor(ct.colorscheme.gocuiFgColor("table_row_active"))