Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 1.24 KB

README.md

File metadata and controls

51 lines (43 loc) · 1.24 KB

CLIPTY

Transform your Command Line Interface (CLI) function into a web browser-based terminal emulator.

Preview

Usage

  1. go get github.com/byebyebruce/clipty
  2. func main() {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
    
        opt := &server.Options{}
        err := clipty.RunServerWithOption(ctx, opt, nil, func(ctx context.Context, params map[string][]string, stdin *os.File, stdout *os.File, stderr *os.File) {
                for i := 0; i < 10; i++ {
                    select {
                    case <-ctx.Done():
                        return
                    default:
                    }
                    time.Sleep(time.Second)
                    fmt.Fprintln(stdout, "sleep", i+1)
                }
                fmt.Fprintln(stdout, "Bye..")
            })
        if err != nil {
            log.Fatal(err)
        }
    }
  3. go run .
  4. open http://localhost:8080

Example

example

SPECIAL THANKS