Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/prcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "stable"
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=2m --verbose
Expand All @@ -31,6 +31,6 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "stable"
go-version-file: "go.mod"
- name: Run tests
run: go test -v ./...
51 changes: 37 additions & 14 deletions cmd/testserver/echo/echo.pb.go

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

5 changes: 5 additions & 0 deletions cmd/testserver/echo/echo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package echo.v1;

import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";

message EvenMoreNestedMessage {
string message = 1;
Expand Down Expand Up @@ -45,6 +47,9 @@ message Message {
float oneof_float_value = 14;
double oneof_double_value = 15;
}

google.protobuf.Timestamp timestamp = 16;
google.protobuf.Duration duration = 17;
}

service EchoService {
Expand Down
39 changes: 38 additions & 1 deletion internal/tui/form/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strconv"
"strings"
"time"

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -152,6 +153,32 @@ func validateFloat(s string) error {
return nil
}

func validateDuration(s string) error {
if s == "" {
return nil
}
_, err := time.ParseDuration(s)
if err != nil {
return fmt.Errorf("must be a valid duration (e.g., 10s)")
}
return nil
}

func validateTimestamp(s string) error {
if s == "" {
return nil
}
_, err := time.Parse(time.RFC3339Nano, s)
if err != nil {
// Try RFC3339 format without nanoseconds
_, err = time.Parse(time.RFC3339, s)
if err != nil {
return fmt.Errorf("must be a valid RFC 3339 timestamp (e.g., 2017-01-15T01:30:15.01Z)")
}
}
return nil
}

func NewFieldFromProto(field protoreflect.FieldDescriptor) *Field {
name := string(field.Name())
kind := field.Kind()
Expand Down Expand Up @@ -181,7 +208,17 @@ func NewFieldFromProto(field protoreflect.FieldDescriptor) *Field {
case protoreflect.BytesKind:
return NewTextField(name, "Enter hex bytes (e.g., deadbeef)...", 512, nil)
case protoreflect.MessageKind:
return NewFieldGroup(name, field)
msgDesc := field.Message()

// support for well-known types
switch msgDesc.FullName() {
case "google.protobuf.Timestamp":
return NewTextField(name, "Enter RFC 3339 timestamp (e.g., 2017-01-15T01:30:15.01Z)...", 64, validateTimestamp)
case "google.protobuf.Duration":
return NewTextField(name, "Enter duration (e.g., 10s)...", 64, validateDuration)
default:
return NewFieldGroup(name, field)
}
default:
return nil
}
Expand Down