Skip to content

Commit

Permalink
add '-o cursor' output type for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Sep 14, 2024
1 parent 78a35bf commit 4840ef5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.10.4 (Unreleased)

### CLI

* Add `-o cursor` output type to `substreams run` for debugging purposes

## v1.10.3

### Server
Expand Down
19 changes: 18 additions & 1 deletion tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"time"

"github.com/streamingfast/bstream"
"github.com/streamingfast/substreams/tools/test"

tea "github.com/charmbracelet/bubbletea"
Expand All @@ -19,7 +20,7 @@ import (

//go:generate go-enum -f=$GOFILE --nocase --marshal --names

// ENUM(TUI, JSON, JSONL, CLOCK)
// ENUM(TUI, JSON, JSONL, CLOCK, CURSOR)
type OutputMode uint

type TUI struct {
Expand Down Expand Up @@ -123,6 +124,8 @@ func (ui *TUI) configureOutputMode(outputMode string) error {
case OutputModeTUI:
ui.prettyPrintOutput = true
case OutputModeJSONL:
case OutputModeCURSOR:
fmt.Println("printing cursor only, no data")
case OutputModeCLOCK:
fmt.Println("Writing clock information only (no data)")
case OutputModeJSON:
Expand Down Expand Up @@ -157,6 +160,12 @@ func (ui *TUI) IncomingMessage(ctx context.Context, resp *pbsubstreamsrpc.Respon
printUndoJSON(m.BlockUndoSignal.LastValidBlock, m.BlockUndoSignal.LastValidCursor)
case OutputModeCLOCK:
fmt.Println("UNDO:", m.BlockUndoSignal.LastValidBlock)
case OutputModeCURSOR:
cur, err := bstream.CursorFromOpaque(m.BlockUndoSignal.LastValidCursor)
if err != nil {
return err
}
fmt.Println(cur.String())
}

case *pbsubstreamsrpc.Response_BlockScopedData:
Expand All @@ -175,6 +184,14 @@ func (ui *TUI) IncomingMessage(ctx context.Context, resp *pbsubstreamsrpc.Respon
case OutputModeCLOCK:
printClock(m.BlockScopedData)
return nil
case OutputModeCURSOR:

cur, err := bstream.CursorFromOpaque(resp.GetBlockScopedData().Cursor)
if err != nil {
return err
}
fmt.Println(cur.String())
return nil
}

ui.seenFirstData = true
Expand Down
16 changes: 11 additions & 5 deletions tui/tui_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4840ef5

Please sign in to comment.