Skip to content

Commit

Permalink
add prefix for enum type
Browse files Browse the repository at this point in the history
  • Loading branch information
xwjdsh authored and Wendell Sun committed Jan 10, 2022
1 parent fbe7341 commit 4620275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions fill/proto/interactive_filler.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (r *resolver) resolveField(f *desc.FieldDescriptor) error {
)
return msgr.resolve()
case descriptorpb.FieldDescriptorProto_TYPE_ENUM:
fmt.Printf("%s%s%s\n", r.color.ForegroundANSI(), f.GetName(), "\033[0m")
return r.resolveEnum(f.GetEnumType())
case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE:
converter = func(v string) (interface{}, error) { return strconv.ParseFloat(v, 64) }
Expand Down
10 changes: 10 additions & 0 deletions prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package prompt

import (
"fmt"
"io"
"os"

Expand Down Expand Up @@ -53,6 +54,15 @@ func (c *Color) NextVal() Color {
return (*c + 1) % 16
}

func (c Color) ForegroundANSI() string {
return fmt.Sprintf("\033[%sm", foregroundANSIColors[c])
}

var foregroundANSIColors = map[Color][]byte{
ColorInitial: {'3', '2'},
ColorBlue: {'9', '4'},
}

type Prompt interface {
// Input reads keyboard input.
// If ctrl+d is entered, Input returns io.EOF.
Expand Down

0 comments on commit 4620275

Please sign in to comment.