Explorar o código

Documented a number of v0.1 roadmap items

arianagiroux hai 1 semana
pai
achega
ad636a73fc

+ 5 - 0
Readme.md

@@ -8,6 +8,11 @@ To compile the project, simply `go build cmd/pingo.go`
 
 ## Roadmap:
 > see ./issues for more. See also [issues-go][issues-go] for a browser TUI.
+
+- `ping.go:// TODO(performance): implement ping message channel buffering`
+- `tui.go:// TODO(chart): dynamically render charts to fit height on not set`
+- `tui.go:// TODO(styling): allow end user to define their own styles when hacking.`
+
  - [ ] "scroll peek" refinements
  - [ ] documentation update
 

+ 0 - 4
cmd/pingo.go

@@ -1,9 +1,5 @@
 // A simple TUI application that charts latency times to specified hosts.
 //
-// TODO(main): determine chart heights dynamically by number of addresses
-//
-// TODO(performance): implement ping message channel buffering
-//
 //	i.e, change the address title to red so long as there is a single -1 in
 //	the display buffer, and a toast notification (???) if a display buffer is
 //	entirely composed of -1

+ 0 - 0
issues/roadmap:-docs-update/blockedby/viewport-to-ping.go


+ 0 - 1
issues/roadmap:-docs-update/description

@@ -1,2 +1 @@
 Provide a fully featured documentation overview in source
-

+ 5 - 0
issues/shift-opinionated-render-to-pingo.go/description

@@ -0,0 +1,5 @@
+Shift opinionated render code from tui.go to cmd/pingo.go
+
+For the sake of modular design (and the sake of bubble publishing), it would make sense to shift all the viewport/header/footer code to cmd/pingo.go.
+
+This change enables a smoother bubble/consumer build separation. Theoretically, it should be relatively easy to "import" and extend the code as a bubble into the tui

+ 1 - 0
issues/shift-opinionated-render-to-pingo.go/status

@@ -0,0 +1 @@
+open

+ 0 - 0
issues/shift-opinionated-render-to-pingo.go/tags/v0.1


+ 2 - 0
ping.go

@@ -1,3 +1,5 @@
+// TODO(performance): implement ping message channel buffering
+//
 // Pingo defines a number of high level functions and data structures to
 // interact with and represent a Ping via Go. Primarily, it defines the
 // Ping() function and Address data structure.

+ 15 - 11
tui.go

@@ -1,3 +1,7 @@
+// TODO(chart): dynamically render charts to fit height on not set
+//
+// TODO(styling): allow end user to define their own styles when hacking.
+//
 // Pingo defines an extensible TUI based on the bubbletea framework (v2). An
 // executable entry point is defined via cmd/pingo.go. For more on this topic,
 // see the Readme.
@@ -113,8 +117,8 @@ type ( // tea.Msg signatures
 
 // Bubbletea model
 type Model struct {
-	Addresses   []Address // as defined in internal/tui/types.go
-	viewport    viewport.Model
+	Addresses   []Address      // as defined in internal/tui/types.go
+	viewport    viewport.Model // mark: opinionated render
 	UpdateSpeed time.Duration
 	ChartHeight int
 	Height      int
@@ -123,7 +127,7 @@ type Model struct {
 
 func InitialModel(addresses []string, speed time.Duration, chartHeight int) Model {
 	var model Model
-	model.viewport.MouseWheelEnabled = true
+	model.viewport.MouseWheelEnabled = true // mark: opinionated render
 	model.UpdateSpeed = speed
 	model.ChartHeight = chartHeight
 
@@ -146,13 +150,13 @@ func (m Model) Tick() tea.Cmd {
 	})
 }
 
-func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // mark: opinionated render
 	var cmd tea.Cmd
 	var cmds []tea.Cmd
 
 	switch msg := msg.(type) {
 	// if case is KeyMsg (keypress)
-	case tea.WindowSizeMsg:
+	case tea.WindowSizeMsg: // mark: opinionated render
 		if m.Width == 0 && m.Height == 0 {
 			m.viewport = viewport.New(
 				viewport.WithHeight(10),
@@ -170,7 +174,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		m.viewport.SetWidth(m.Width)
 		m.viewport.YPosition = 1
 
-	case tea.KeyPressMsg:
+	case tea.KeyPressMsg: // mark: opinionated render
 		if k := msg.String(); k == "j" { // scroll down
 			m.viewport.ScrollDown(1)
 		} else if k == "k" { // scroll up
@@ -196,7 +200,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	return m, tea.Batch(cmds...)
 }
 
-func (m Model) View() tea.View {
+func (m Model) View() tea.View { // mark: opinionated render
 	content := fmt.Sprintf("%s%s\n%s", m.header(), m.viewport.View(), m.footer())
 
 	var v tea.View
@@ -204,7 +208,7 @@ func (m Model) View() tea.View {
 	v.AltScreen = true
 	return v
 }
-func (m Model) Render() string {
+func (m Model) Render() string { // mark: opinionated render
 	var output string
 	for _, address := range m.Addresses {
 		if len(address.Results) == 0 {
@@ -250,13 +254,13 @@ func (m Model) Render() string {
 	return output
 }
 
-func (m Model) header() string { return titleStyle.Width(m.Width).Render("pingo v0") }
+func (m Model) header() string { return titleStyle.Width(m.Width).Render("pingo v0") } // mark: opinionated render
 
-func (m Model) footer() string {
+func (m Model) footer() string { // mark: opinionated render
 	return footerStyle.Width(m.Width).Render("j/k: down/up\t|\tq/ctrl-c/esc: quit")
 }
 
-func (m Model) getVerticalMargin() int { return lipgloss.Height(m.header() + m.footer()) }
+func (m Model) getVerticalMargin() int { return lipgloss.Height(m.header() + m.footer()) } // mark: opinionated render
 
 // Returns a batched set of tea.Cmd functions for each address.
 func (m Model) Poll() tea.Cmd {

+ 1 - 1
tui_test.go

@@ -77,7 +77,7 @@ func Test_Model_Update_handle_windowsize(t *testing.T) {
 
 	model, cmd := testModel.Update(testSize)
 	assert.Nil(t, cmd)
-	assert.Equal(t, 200-2, model.(Model).viewport.Height()) // TODO make margin height accessible to tests
+	assert.Equal(t, 200-2, model.(Model).viewport.Height())
 }
 
 // skipped until a testing paradigm can be determined (func has sig)