diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-06-04 22:24:24 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-06-04 22:24:24 +0200 |
commit | 2b2ea59fc9fa0ff5bb17251cc9345391346021a2 (patch) | |
tree | d5f918b70c8a2565d9d5885d3edf3e3bef737d5c | |
parent | fb074d4decf6a1406ad39737741a061e1b5bc2d1 (diff) |
Quit command
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | main/Main.hs | 15 |
2 files changed, 18 insertions, 3 deletions
@@ -40,6 +40,9 @@ followed by command name and parameters (if any) separated by spaces. When a conversation is selected, message to send there is entered directly on the command prompt. +The session can be terminated either by end-of-input (typically `Ctrl-d`) or +using the `/quit` command. + ### Messaging `/peers` @@ -132,6 +135,9 @@ re-established by either side. `/update-identity` Interactively update current identity information +`/quit` +Quit the erebos tool. + Storage ------- diff --git a/main/Main.hs b/main/Main.hs index df904a2..ca980ca 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -292,9 +292,12 @@ interactiveLoop st opts = runInputT inputSettings $ do , ciSetContextOptions = \ctxs -> liftIO $ modifyMVar_ contextOptions $ const $ return ctxs } case res of - Right cstate' -> return cstate' - Left err -> do lift $ lift $ extPrint $ "Error: " ++ err - return cstate + Right cstate' + | csQuit cstate' -> mzero + | otherwise -> return cstate' + Left err -> do + lift $ lift $ extPrint $ "Error: " ++ err + return cstate let loop (Just cstate) = runMaybeT (process cstate) >>= loop loop Nothing = return () @@ -305,6 +308,7 @@ interactiveLoop st opts = runInputT inputSettings $ do , csIceSessions = [] #endif , csIcePeer = Nothing + , csQuit = False } @@ -324,6 +328,7 @@ data CommandState = CommandState , csIceSessions :: [IceSession] #endif , csIcePeer :: Maybe Peer + , csQuit :: Bool } data CommandContext = NoContext @@ -399,6 +404,7 @@ commands = , ("ice-connect", cmdIceConnect) , ("ice-send", cmdIceSend) #endif + , ("quit", cmdQuit) ] commandCompletion :: CompletionFunc IO @@ -649,3 +655,6 @@ cmdIceSend = void $ do liftIO $ serverPeerIce server s #endif + +cmdQuit :: Command +cmdQuit = modify $ \s -> s { csQuit = True } |