package clitest
import (
)
var Styles = ui.RuneStylesheet{
'_': ui.Underlined,
'b': ui.Bold,
'*': ui.Stylings(ui.Bold, ui.FgWhite, ui.BgMagenta),
'+': ui.Inverse,
'/': ui.FgBlue,
'#': ui.Stylings(ui.Inverse, ui.FgBlue),
'!': ui.FgRed,
'?': ui.Stylings(ui.FgBrightWhite, ui.BgRed),
'-': ui.FgMagenta,
'X': ui.Stylings(ui.Inverse, ui.FgMagenta),
'v': ui.FgGreen,
'V': ui.Stylings(ui.Underlined, ui.FgGreen),
'$': ui.FgMagenta,
'c': ui.FgCyan,
}
type Fixture struct {
App cli.App
TTY TTYCtrl
width int
codeCh <-chan string
errCh <-chan error
}
func ( ...func(*cli.AppSpec, TTYCtrl)) *Fixture {
, := NewFakeTTY()
:= cli.AppSpec{TTY: }
for , := range {
(&, )
}
:= cli.NewApp()
, := StartReadCode(.ReadCode)
, := .Size()
return &Fixture{, , , , }
}
func ( func(*cli.AppSpec)) func(*cli.AppSpec, TTYCtrl) {
return func( *cli.AppSpec, TTYCtrl) { () }
}
func ( func(TTYCtrl)) func(*cli.AppSpec, TTYCtrl) {
return func( *cli.AppSpec, TTYCtrl) { () }
}
func ( *Fixture) () (string, error) {
return <-.codeCh, <-.errCh
}
func ( *Fixture) () {
.App.CommitEOF()
.Wait()
}
func ( *Fixture) ( ...interface{}) *term.Buffer {
return term.NewBufferBuilder(.width).MarkLines(...).Buffer()
}
func ( *Fixture) ( *testing.T, ...interface{}) {
.Helper()
.TTY.TestBuffer(, .MakeBuffer(...))
}
func ( *Fixture) ( *testing.T, ...interface{}) {
.Helper()
.TTY.TestNotesBuffer(, .MakeBuffer(...))
}
func ( func() (string, error)) (<-chan string, <-chan error) {
:= make(chan string, 1)
:= make(chan error, 1)
go func() {
, := ()
<-
<-
close()
close()
}()
return ,
}