File tree 4 files changed +24
-3
lines changed
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,14 @@ createInterface :: forall eff. Completer eff -> Eff (console :: CONSOLE | eff) I
63
63
64
64
Create an interface with the specified completion function.
65
65
66
+ #### ` close `
67
+
68
+ ``` purescript
69
+ close :: forall eff. Interface -> Eff (console :: CONSOLE | eff) Interface
70
+ ```
71
+
72
+ Close the specified ` Interface ` .
73
+
66
74
#### ` noCompletion `
67
75
68
76
``` purescript
Original file line number Diff line number Diff line change @@ -46,3 +46,10 @@ exports.createInterface = function(completer) {
46
46
} ) ;
47
47
} ;
48
48
} ;
49
+
50
+ exports . close = function ( readline ) {
51
+ return function ( ) {
52
+ readline . close ( ) ;
53
+ return readline ;
54
+ } ;
55
+ } ;
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ foreign import setPrompt :: forall eff. String -> Int -> Interface -> Eff (conso
33
33
-- | Create an interface with the specified completion function.
34
34
foreign import createInterface :: forall eff . Completer eff -> Eff (console :: CONSOLE | eff ) Interface
35
35
36
+ -- | Close the specified `Interface`.
37
+ foreign import close :: forall eff . Interface -> Eff (console :: CONSOLE | eff ) Interface
38
+
36
39
-- | A completion function which offers no completions.
37
40
noCompletion :: forall eff . Completer eff
38
41
noCompletion s = return { completions: [] , matched: s }
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ main = do
12
12
13
13
setPrompt " > " 2 interface
14
14
prompt interface
15
- setLineHandler interface $ \s -> do
16
- log $ " You typed: " ++ s
17
- prompt interface
15
+ setLineHandler interface $ \s ->
16
+ if s == " quit"
17
+ then close interface
18
+ else do
19
+ log $ " You typed: " ++ s
20
+ prompt interface
You can’t perform that action at this time.
0 commit comments