1// +build !windows,!linux,!darwin,!openbsd,!freebsd,!netbsd 2 3package liner 4 5import ( 6 "bufio" 7 "errors" 8 "os" 9) 10 11// State represents an open terminal 12type State struct { 13 commonState 14} 15 16// Prompt displays p, and then waits for user input. Prompt does not support 17// line editing on this operating system. 18func (s *State) Prompt(p string) (string, error) { 19 return s.promptUnsupported(p) 20} 21 22// PasswordPrompt is not supported in this OS. 23func (s *State) PasswordPrompt(p string) (string, error) { 24 return "", errors.New("liner: function not supported in this terminal") 25} 26 27// NewLiner initializes a new *State 28// 29// Note that this operating system uses a fallback mode without line 30// editing. Patches welcome. 31func NewLiner() *State { 32 var s State 33 s.r = bufio.NewReader(os.Stdin) 34 return &s 35} 36 37// Close returns the terminal to its previous mode 38func (s *State) Close() error { 39 return nil 40} 41 42// TerminalSupported returns false because line editing is not 43// supported on this platform. 44func TerminalSupported() bool { 45 return false 46} 47 48type noopMode struct{} 49 50func (n noopMode) ApplyMode() error { 51 return nil 52} 53 54// TerminalMode returns a noop InputModeSetter on this platform. 55func TerminalMode() (ModeApplier, error) { 56 return noopMode{}, nil 57} 58