package
module
Version:
v0.0.0-...-30ec66f
Opens a new window with list of versions in this module.
Published: Mar 15, 2024
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 7
Opens a new window with list of known importers.
README
¶
CLIPTY
Transform your Command Line Interface (CLI) function into a web browser-based terminal emulator.
Preview
Usage
-
go get github.com/byebyebruce/clipty
-
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)
}
}
-
go run .
- open http://localhost:8080
Example
example
SPECIAL THANKS
Documentation
¶
RunServer runs a cli web server
MainFunc is CLI main loop function.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.