Skip to content
/ readline Public
forked from gohxs/readline

Readline is a pure go(golang) implementation for GNU-Readline kind library

License

Notifications You must be signed in to change notification settings

yuce/readline

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readline

fork of readline made by chzyer

readline: https://github.com/chzyer/readline

I wanted a feature to transform the output of the input buffer and since chzyer doesn't seem active #121 so I just created this fork

Highlighter example:

doc

Snip of the sample gif shown above Highlighting with chroma

package main

import (
  "bytes"
  "log"

  "github.com/alecthomas/chroma/quick"
  "github.com/gohxs/readline"
)

func display(input string) string {
  buf := bytes.NewBuffer([]byte{})
  err := quick.Highlight(buf, input, "postgres", "terminal16m", "monokai")
  if err != nil {
    log.Fatal(err)
  }
  return buf.String()
}
func main() {
  log.SetFlags(log.Lshortfile | log.LstdFlags)
  term, err := readline.NewEx(&readline.Config{
    Prompt: "SQLIrl> ",
    Output: display,
  })
  if err != nil {
    log.Fatal(err)
  }
  for {
    line, err := term.Readline()
    if err != nil {
      log.Fatal(err)
    }
    //... do things
    log.Println("E:", line)
  }
}

About

Readline is a pure go(golang) implementation for GNU-Readline kind library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%