From 80855a15a9e89af5920dc7aae547a231ddbc96b6 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Thu, 21 Mar 2024 00:17:29 -0700 Subject: [PATCH] Minor reformatting. --- coindesk/assets.go | 326 +++++++++++++++++++++++++++++++++++++++++++++ coindesk/model.go | 325 -------------------------------------------- moon/moon.go | 5 +- tui/tui.go | 40 +++--- 4 files changed, 353 insertions(+), 343 deletions(-) create mode 100644 coindesk/assets.go diff --git a/coindesk/assets.go b/coindesk/assets.go new file mode 100644 index 0000000..32f8908 --- /dev/null +++ b/coindesk/assets.go @@ -0,0 +1,326 @@ +package coindesk + +const ( + BTC Asset = "BTC" + ETH Asset = "ETH" + XRP Asset = "XRP" + BCH Asset = "BCH" + EOS Asset = "EOS" + XLM Asset = "XLM" + LTC Asset = "LTC" + ADA Asset = "ADA" + XMR Asset = "XMR" + DASH Asset = "DASH" + IOTA Asset = "IOTA" + TRX Asset = "TRX" + NEO Asset = "NEO" + ETC Asset = "ETC" + XEM Asset = "XEM" + ZEC Asset = "ZEC" + BTG Asset = "BTG" + LSK Asset = "LSK" + QTUM Asset = "QTUM" + BSV Asset = "BSV" + DOGE Asset = "DOGE" + DCR Asset = "DCR" + USDT Asset = "USDT" + USDC Asset = "USDC" + LINK Asset = "LINK" + XTZ Asset = "XTZ" + ZRX Asset = "ZRX" + DAI Asset = "DAI" + BAT Asset = "BAT" + OXT Asset = "OXT" + ALGO Asset = "ALGO" + ATOM Asset = "ATOM" + KNC Asset = "KNC" + OMG Asset = "OMG" + ANT Asset = "ANT" + REP Asset = "REP" + BAND Asset = "BAND" + BTT Asset = "BTT" + MANA Asset = "MANA" + FET Asset = "FET" + ICX Asset = "ICX" + KAVA Asset = "KAVA" + LRC Asset = "LRC" + MKR Asset = "MKR" + MLN Asset = "MLN" + NANO Asset = "NANO" + NMR Asset = "NMR" + PAXG Asset = "PAXG" + USDP Asset = "USDP" + SC Asset = "SC" + STORJ Asset = "STORJ" + WAVES Asset = "WAVES" + FIL Asset = "FIL" + CVC Asset = "CVC" + DNT Asset = "DNT" + REN Asset = "REN" + BNT Asset = "BNT" + WBTC Asset = "WBTC" + GRT Asset = "GRT" + UNI Asset = "UNI" + DOT Asset = "DOT" + YFI Asset = "YFI" + AAVE Asset = "AAVE" + MATIC Asset = "MATIC" + AMP Asset = "AMP" + CELO Asset = "CELO" + COMP Asset = "COMP" + CRV Asset = "CRV" + RLC Asset = "RLC" + KSM Asset = "KSM" + NKN Asset = "NKN" + SHIB Asset = "SHIB" + SKL Asset = "SKL" + SNX Asset = "SNX" + LUNC Asset = "LUNC" + UMA Asset = "UMA" + ICP Asset = "ICP" + SOL Asset = "SOL" + AVAX Asset = "AVAX" + UST Asset = "UST" + ENJ Asset = "ENJ" + IOTX Asset = "IOTX" + AXS Asset = "AXS" + XYO Asset = "XYO" + SUSHI Asset = "SUSHI" + ANKR Asset = "ANKR" + CHZ Asset = "CHZ" + LPT Asset = "LPT" + COTI Asset = "COTI" + KEEP Asset = "KEEP" + SAND Asset = "SAND" + GALA Asset = "GALA" + APE Asset = "APE" + CRO Asset = "CRO" + ACHP Asset = "ACHP" + JASMY Asset = "JASMY" + REQ Asset = "REQ" + SLP Asset = "SLP" + NEAR Asset = "NEAR" + MBOX Asset = "MBOX" + POLIS Asset = "POLIS" + MOVR Asset = "MOVR" + POLS Asset = "POLS" + QUICK Asset = "QUICK" + MINA Asset = "MINA" + IMX Asset = "IMX" + XEC Asset = "XEC" + NEXO Asset = "NEXO" + RUNE Asset = "RUNE" + QNT Asset = "QNT" + VET Asset = "VET" + CAKE Asset = "CAKE" + BNB Asset = "BNB" + THETA Asset = "THETA" + HBAR Asset = "HBAR" + FTM Asset = "FTM" + RVN Asset = "RVN" + ZIL Asset = "ZIL" + DGB Asset = "DGB" + FTT Asset = "FTT" + ENS Asset = "ENS" + WRX Asset = "WRX" + WAXP Asset = "WAXP" + EGLD Asset = "EGLD" + BUSD Asset = "BUSD" + CEL Asset = "CEL" + OP Asset = "OP" + LUNA Asset = "LUNA" + RAY Asset = "RAY" + FLOW Asset = "FLOW" + AUDIO Asset = "AUDIO" + CKB Asset = "CKB" + VGX Asset = "VGX" + YGG Asset = "YGG" + CHR Asset = "CHR" + STMX Asset = "STMX" + SXP Asset = "SXP" + INJ Asset = "INJ" + JOE Asset = "JOE" + POLY Asset = "POLY" + STX Asset = "STX" + SFP Asset = "SFP" + FARM Asset = "FARM" + XVG Asset = "XVG" + CLV Asset = "CLV" + WOO Asset = "WOO" + GLMR Asset = "GLMR" + STEEM Asset = "STEEM" + RARE Asset = "RARE" + IDEX Asset = "IDEX" + SRM Asset = "SRM" + PYR Asset = "PYR" + MIR Asset = "MIR" + SYS Asset = "SYS" + ALPACA Asset = "ALPACA" + QSP Asset = "QSP" + SCRT Asset = "SCRT" + SUN Asset = "SUN" + APT Asset = "APT" + MASK Asset = "MASK" + DYDX Asset = "DYDX" + CVX Asset = "CVX" + GMT Asset = "GMT" + CTSI Asset = "CTSI" + METIS Asset = "METIS" + FORTH Asset = "FORTH" + RBN Asset = "RBN" + SAMO Asset = "SAMO" + SPELL Asset = "SPELL" + LDO Asset = "LDO" + ARB Asset = "ARB" + BLUR Asset = "BLUR" + GAS Asset = "GAS" + RACA Asset = "RACA" + BABYDOGE Asset = "BABYDOGE" + FLOKI Asset = "FLOKI" + HOT Asset = "HOT" + BFC Asset = "BFC" + KISHU Asset = "KISHU" + ELON Asset = "ELON" + SAITAMA Asset = "SAITAMA" + REEF Asset = "REEF" + CEEK Asset = "CEEK" + ATLAS Asset = "ATLAS" + LOOKS Asset = "LOOKS" + WIN Asset = "WIN" + ONE Asset = "ONE" + DENT Asset = "DENT" + GST Asset = "GST" + TWT Asset = "TWT" + HNT Asset = "HNT" + AGLD Asset = "AGLD" + BTRST Asset = "BTRST" + ETHW Asset = "ETHW" + ILV Asset = "ILV" + RARI Asset = "RARI" + STG Asset = "STG" + SYN Asset = "SYN" + TOKE Asset = "TOKE" + BLZ Asset = "BLZ" + FLR Asset = "FLR" + FIS Asset = "FIS" + GNS Asset = "GNS" + ID Asset = "ID" + PEPE Asset = "PEPE" + DIA Asset = "DIA" + TLM Asset = "TLM" + XCN Asset = "XCN" + BIT Asset = "BIT" + RPL Asset = "RPL" + RNDR Asset = "RNDR" + ONEINCH Asset = "1INCH" + BAL Asset = "BAL" + T Asset = "T" + GNO Asset = "GNO" + ASTR Asset = "ASTR" + GLM Asset = "GLM" + OCEAN Asset = "OCEAN" + BICO Asset = "BICO" + CELR Asset = "CELR" + LQTY Asset = "LQTY" + TRAC Asset = "TRAC" + ZEN Asset = "ZEN" + API3 Asset = "API3" + PLA Asset = "PLA" + AXL Asset = "AXL" + HFT Asset = "HFT" + MC Asset = "MC" + C98 Asset = "C98" + GAL Asset = "GAL" + GTC Asset = "GTC" + RAD Asset = "RAD" + POWR Asset = "POWR" + POND Asset = "POND" + ALICE Asset = "ALICE" + TRU Asset = "TRU" + OGN Asset = "OGN" + DAR Asset = "DAR" + BADGER Asset = "BADGER" + GHST Asset = "GHST" + LCX Asset = "LCX" + ARPA Asset = "ARPA" + MXC Asset = "MXC" + PERP Asset = "PERP" + LOKA Asset = "LOKA" + BOBA Asset = "BOBA" + BOND Asset = "BOND" + ALCX Asset = "ALCX" + KP3R Asset = "KP3R" + TON Asset = "TON" + AR Asset = "AR" + AVA Asset = "AVA" + BONE Asset = "BONE" + BONK Asset = "BONK" + CORE Asset = "CORE" + CSPR Asset = "CSPR" + DG Asset = "DG" + ERN Asset = "ERN" + FXS Asset = "FXS" + GMX Asset = "GMX" + GT Asset = "GT" + GUSD Asset = "GUSD" + HMT Asset = "HMT" + HT Asset = "HT" + KCS Asset = "KCS" + KLAY Asset = "KLAY" + LEO Asset = "LEO" + MPL Asset = "MPL" + OKB Asset = "OKB" + PIT Asset = "PIT" + OSMO Asset = "OSMO" + RLY Asset = "RLY" + SANTOS Asset = "SANTOS" + SUI Asset = "SUI" + SWEAT Asset = "SWEAT" + TUSD Asset = "TUSD" + TVK Asset = "TVK" + UNFI Asset = "UNFI" + USDD Asset = "USDD" + VLX Asset = "VLX" + WEMIX Asset = "WEMIX" + XDC Asset = "XDC" + XRD Asset = "XRD" + FB Asset = "FB" + BRISE Asset = "BRISE" + KAS Asset = "KAS" + XEN Asset = "XEN" + HAM Asset = "HAM" + TAMA Asset = "TAMA" + KDA Asset = "KDA" + CFX Asset = "CFX" + VRA Asset = "VRA" + BDX Asset = "BDX" + RDNT Asset = "RDNT" + WLD Asset = "WLD" + AGIX Asset = "AGIX" + PYUSD Asset = "PYUSD" + MOON Asset = "MOON" + SEI Asset = "SEI" + AKT Asset = "AKT" + MAGIC Asset = "MAGIC" + SNT Asset = "SNT" + ALPHA Asset = "ALPHA" + ALI Asset = "ALI" + CQT Asset = "CQT" + HIGH Asset = "HIGH" + AERGO Asset = "AERGO" + GODS Asset = "GODS" + ZBC Asset = "ZBC" + ACA Asset = "ACA" + MDT Asset = "MDT" + LIT Asset = "LIT" + QI Asset = "QI" + AURORA Asset = "AURORA" + TOMI Asset = "TOMI" + XCH Asset = "XCH" + MANTA Asset = "MANTA" + PYTH Asset = "PYTH" + STRK Asset = "STRK" + ETHFI Asset = "ETHFI" + TIA Asset = "TIA" + EETH Asset = "EETH" +) diff --git a/coindesk/model.go b/coindesk/model.go index 0c4324d..63347c1 100644 --- a/coindesk/model.go +++ b/coindesk/model.go @@ -10,331 +10,6 @@ import ( // Asset is a cryptocurrency, like Bitcoin, Ethereum, etc. type Asset string -const ( - BTC Asset = "BTC" - ETH Asset = "ETH" - XRP Asset = "XRP" - BCH Asset = "BCH" - EOS Asset = "EOS" - XLM Asset = "XLM" - LTC Asset = "LTC" - ADA Asset = "ADA" - XMR Asset = "XMR" - DASH Asset = "DASH" - IOTA Asset = "IOTA" - TRX Asset = "TRX" - NEO Asset = "NEO" - ETC Asset = "ETC" - XEM Asset = "XEM" - ZEC Asset = "ZEC" - BTG Asset = "BTG" - LSK Asset = "LSK" - QTUM Asset = "QTUM" - BSV Asset = "BSV" - DOGE Asset = "DOGE" - DCR Asset = "DCR" - USDT Asset = "USDT" - USDC Asset = "USDC" - LINK Asset = "LINK" - XTZ Asset = "XTZ" - ZRX Asset = "ZRX" - DAI Asset = "DAI" - BAT Asset = "BAT" - OXT Asset = "OXT" - ALGO Asset = "ALGO" - ATOM Asset = "ATOM" - KNC Asset = "KNC" - OMG Asset = "OMG" - ANT Asset = "ANT" - REP Asset = "REP" - BAND Asset = "BAND" - BTT Asset = "BTT" - MANA Asset = "MANA" - FET Asset = "FET" - ICX Asset = "ICX" - KAVA Asset = "KAVA" - LRC Asset = "LRC" - MKR Asset = "MKR" - MLN Asset = "MLN" - NANO Asset = "NANO" - NMR Asset = "NMR" - PAXG Asset = "PAXG" - USDP Asset = "USDP" - SC Asset = "SC" - STORJ Asset = "STORJ" - WAVES Asset = "WAVES" - FIL Asset = "FIL" - CVC Asset = "CVC" - DNT Asset = "DNT" - REN Asset = "REN" - BNT Asset = "BNT" - WBTC Asset = "WBTC" - GRT Asset = "GRT" - UNI Asset = "UNI" - DOT Asset = "DOT" - YFI Asset = "YFI" - AAVE Asset = "AAVE" - MATIC Asset = "MATIC" - AMP Asset = "AMP" - CELO Asset = "CELO" - COMP Asset = "COMP" - CRV Asset = "CRV" - RLC Asset = "RLC" - KSM Asset = "KSM" - NKN Asset = "NKN" - SHIB Asset = "SHIB" - SKL Asset = "SKL" - SNX Asset = "SNX" - LUNC Asset = "LUNC" - UMA Asset = "UMA" - ICP Asset = "ICP" - SOL Asset = "SOL" - AVAX Asset = "AVAX" - UST Asset = "UST" - ENJ Asset = "ENJ" - IOTX Asset = "IOTX" - AXS Asset = "AXS" - XYO Asset = "XYO" - SUSHI Asset = "SUSHI" - ANKR Asset = "ANKR" - CHZ Asset = "CHZ" - LPT Asset = "LPT" - COTI Asset = "COTI" - KEEP Asset = "KEEP" - SAND Asset = "SAND" - GALA Asset = "GALA" - APE Asset = "APE" - CRO Asset = "CRO" - ACHP Asset = "ACHP" - JASMY Asset = "JASMY" - REQ Asset = "REQ" - SLP Asset = "SLP" - NEAR Asset = "NEAR" - MBOX Asset = "MBOX" - POLIS Asset = "POLIS" - MOVR Asset = "MOVR" - POLS Asset = "POLS" - QUICK Asset = "QUICK" - MINA Asset = "MINA" - IMX Asset = "IMX" - XEC Asset = "XEC" - NEXO Asset = "NEXO" - RUNE Asset = "RUNE" - QNT Asset = "QNT" - VET Asset = "VET" - CAKE Asset = "CAKE" - BNB Asset = "BNB" - THETA Asset = "THETA" - HBAR Asset = "HBAR" - FTM Asset = "FTM" - RVN Asset = "RVN" - ZIL Asset = "ZIL" - DGB Asset = "DGB" - FTT Asset = "FTT" - ENS Asset = "ENS" - WRX Asset = "WRX" - WAXP Asset = "WAXP" - EGLD Asset = "EGLD" - BUSD Asset = "BUSD" - CEL Asset = "CEL" - OP Asset = "OP" - LUNA Asset = "LUNA" - RAY Asset = "RAY" - FLOW Asset = "FLOW" - AUDIO Asset = "AUDIO" - CKB Asset = "CKB" - VGX Asset = "VGX" - YGG Asset = "YGG" - CHR Asset = "CHR" - STMX Asset = "STMX" - SXP Asset = "SXP" - INJ Asset = "INJ" - JOE Asset = "JOE" - POLY Asset = "POLY" - STX Asset = "STX" - SFP Asset = "SFP" - FARM Asset = "FARM" - XVG Asset = "XVG" - CLV Asset = "CLV" - WOO Asset = "WOO" - GLMR Asset = "GLMR" - STEEM Asset = "STEEM" - RARE Asset = "RARE" - IDEX Asset = "IDEX" - SRM Asset = "SRM" - PYR Asset = "PYR" - MIR Asset = "MIR" - SYS Asset = "SYS" - ALPACA Asset = "ALPACA" - QSP Asset = "QSP" - SCRT Asset = "SCRT" - SUN Asset = "SUN" - APT Asset = "APT" - MASK Asset = "MASK" - DYDX Asset = "DYDX" - CVX Asset = "CVX" - GMT Asset = "GMT" - CTSI Asset = "CTSI" - METIS Asset = "METIS" - FORTH Asset = "FORTH" - RBN Asset = "RBN" - SAMO Asset = "SAMO" - SPELL Asset = "SPELL" - LDO Asset = "LDO" - ARB Asset = "ARB" - BLUR Asset = "BLUR" - GAS Asset = "GAS" - RACA Asset = "RACA" - BABYDOGE Asset = "BABYDOGE" - FLOKI Asset = "FLOKI" - HOT Asset = "HOT" - BFC Asset = "BFC" - KISHU Asset = "KISHU" - ELON Asset = "ELON" - SAITAMA Asset = "SAITAMA" - REEF Asset = "REEF" - CEEK Asset = "CEEK" - ATLAS Asset = "ATLAS" - LOOKS Asset = "LOOKS" - WIN Asset = "WIN" - ONE Asset = "ONE" - DENT Asset = "DENT" - GST Asset = "GST" - TWT Asset = "TWT" - HNT Asset = "HNT" - AGLD Asset = "AGLD" - BTRST Asset = "BTRST" - ETHW Asset = "ETHW" - ILV Asset = "ILV" - RARI Asset = "RARI" - STG Asset = "STG" - SYN Asset = "SYN" - TOKE Asset = "TOKE" - BLZ Asset = "BLZ" - FLR Asset = "FLR" - FIS Asset = "FIS" - GNS Asset = "GNS" - ID Asset = "ID" - PEPE Asset = "PEPE" - DIA Asset = "DIA" - TLM Asset = "TLM" - XCN Asset = "XCN" - BIT Asset = "BIT" - RPL Asset = "RPL" - RNDR Asset = "RNDR" - ONEINCH Asset = "1INCH" - BAL Asset = "BAL" - T Asset = "T" - GNO Asset = "GNO" - ASTR Asset = "ASTR" - GLM Asset = "GLM" - OCEAN Asset = "OCEAN" - BICO Asset = "BICO" - CELR Asset = "CELR" - LQTY Asset = "LQTY" - TRAC Asset = "TRAC" - ZEN Asset = "ZEN" - API3 Asset = "API3" - PLA Asset = "PLA" - AXL Asset = "AXL" - HFT Asset = "HFT" - MC Asset = "MC" - C98 Asset = "C98" - GAL Asset = "GAL" - GTC Asset = "GTC" - RAD Asset = "RAD" - POWR Asset = "POWR" - POND Asset = "POND" - ALICE Asset = "ALICE" - TRU Asset = "TRU" - OGN Asset = "OGN" - DAR Asset = "DAR" - BADGER Asset = "BADGER" - GHST Asset = "GHST" - LCX Asset = "LCX" - ARPA Asset = "ARPA" - MXC Asset = "MXC" - PERP Asset = "PERP" - LOKA Asset = "LOKA" - BOBA Asset = "BOBA" - BOND Asset = "BOND" - ALCX Asset = "ALCX" - KP3R Asset = "KP3R" - TON Asset = "TON" - AR Asset = "AR" - AVA Asset = "AVA" - BONE Asset = "BONE" - BONK Asset = "BONK" - CORE Asset = "CORE" - CSPR Asset = "CSPR" - DG Asset = "DG" - ERN Asset = "ERN" - FXS Asset = "FXS" - GMX Asset = "GMX" - GT Asset = "GT" - GUSD Asset = "GUSD" - HMT Asset = "HMT" - HT Asset = "HT" - KCS Asset = "KCS" - KLAY Asset = "KLAY" - LEO Asset = "LEO" - MPL Asset = "MPL" - OKB Asset = "OKB" - PIT Asset = "PIT" - OSMO Asset = "OSMO" - RLY Asset = "RLY" - SANTOS Asset = "SANTOS" - SUI Asset = "SUI" - SWEAT Asset = "SWEAT" - TUSD Asset = "TUSD" - TVK Asset = "TVK" - UNFI Asset = "UNFI" - USDD Asset = "USDD" - VLX Asset = "VLX" - WEMIX Asset = "WEMIX" - XDC Asset = "XDC" - XRD Asset = "XRD" - FB Asset = "FB" - BRISE Asset = "BRISE" - KAS Asset = "KAS" - XEN Asset = "XEN" - HAM Asset = "HAM" - TAMA Asset = "TAMA" - KDA Asset = "KDA" - CFX Asset = "CFX" - VRA Asset = "VRA" - BDX Asset = "BDX" - RDNT Asset = "RDNT" - WLD Asset = "WLD" - AGIX Asset = "AGIX" - PYUSD Asset = "PYUSD" - MOON Asset = "MOON" - SEI Asset = "SEI" - AKT Asset = "AKT" - MAGIC Asset = "MAGIC" - SNT Asset = "SNT" - ALPHA Asset = "ALPHA" - ALI Asset = "ALI" - CQT Asset = "CQT" - HIGH Asset = "HIGH" - AERGO Asset = "AERGO" - GODS Asset = "GODS" - ZBC Asset = "ZBC" - ACA Asset = "ACA" - MDT Asset = "MDT" - LIT Asset = "LIT" - QI Asset = "QI" - AURORA Asset = "AURORA" - TOMI Asset = "TOMI" - XCH Asset = "XCH" - MANTA Asset = "MANTA" - PYTH Asset = "PYTH" - STRK Asset = "STRK" - ETHFI Asset = "ETHFI" - TIA Asset = "TIA" - EETH Asset = "EETH" -) - // Response represents the general top-level format of Coindesk API responses. type Response[T any] struct { StatusCode int `json:"statusCode"` diff --git a/moon/moon.go b/moon/moon.go index 6572a9d..e524f5c 100644 --- a/moon/moon.go +++ b/moon/moon.go @@ -91,7 +91,10 @@ func (m *Math) Refresh(ctx context.Context) (err error) { days := now.Sub(c.StartingDate).Hours() / 24 c.CDPR = CDPR(days, c.Gain) if c.CDPR > 1 { - c.Projections = ProjectDates(now, float64(m.CurrentPrice), c.CDPR, m.Goals) + c.Projections = ProjectDates( + now, float64(m.CurrentPrice), + c.CDPR, m.Goals, + ) } else { c.Projections.Dates = nil } diff --git a/tui/tui.go b/tui/tui.go index 042bac1..a495187 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -13,10 +13,6 @@ import ( "github.com/charmbracelet/lipgloss" ) -var baseStyle = lipgloss.NewStyle(). - BorderStyle(lipgloss.NormalBorder()). - BorderForeground(lipgloss.Color("240")) - type Model struct { math moon.Math @@ -48,10 +44,11 @@ func New(cfg config.Data) Model { {Title: "Labels", Width: 8}, } for i := range math.Columns { - projectionCols = append(projectionCols, table.Column{ - Title: math.Columns[i].Base.Label(), - Width: 10, - }) + projectionCols = append(projectionCols, + table.Column{ + Title: math.Columns[i].Base.Label(), + Width: 10, + }) } projections := table.New( table.WithColumns(projectionCols), @@ -61,7 +58,8 @@ func New(cfg config.Data) Model { indicator := spinner.New() indicator.Spinner = spinner.Points - indicator.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("69")) + indicator.Style = lipgloss.NewStyle(). + Foreground(lipgloss.Color("69")) return Model{ math: math, @@ -88,18 +86,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { _ = m.math.Refresh(context.TODO()) return m.math } - case spinner.TickMsg: - var cmd tea.Cmd - m.indicator, cmd = m.indicator.Update(msg) - return m, cmd case moon.Math: m.math = msg m.reloading = false refillPrice(&m) refillProjections(&m) - return m, tea.Tick(time.Second*30, func(t time.Time) tea.Msg { - return refresh{} - }) + return m, tea.Tick(time.Second*30, + func(t time.Time) tea.Msg { + return refresh{} + }) + case spinner.TickMsg: + var cmd tea.Cmd + m.indicator, cmd = m.indicator.Update(msg) + return m, cmd case tea.KeyMsg: switch msg.String() { case "ctrl+c", "q", "esc": @@ -113,7 +112,10 @@ type refresh struct{} func refillPrice(m *Model) { rows := []table.Row{ - []string{string(m.math.Asset), fmt.Sprintf("$%0.2f", m.math.CurrentPrice)}, + []string{ + string(m.math.Asset), + fmt.Sprintf("$%0.2f", m.math.CurrentPrice), + }, } m.prices.SetRows(rows) } @@ -160,3 +162,7 @@ func (m Model) View() string { ) return s + "\n" } + +var baseStyle = lipgloss.NewStyle(). + BorderStyle(lipgloss.NormalBorder()). + BorderForeground(lipgloss.Color("240"))