aboutsummaryrefslogtreecommitdiff
path: root/lib/Daffm/Action/Commands.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-05 20:21:13 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-08 13:05:32 +0530
commit8cc1763237f9f12d25cf00735ce63c5655877899 (patch)
tree2ac9e6cd021327b6eb30ab7305e24aec68df3ab3 /lib/Daffm/Action/Commands.hs
parent0979d4e678514a8e0cdcbe1fbb174667c5361c8a (diff)
downloaddaffm-8cc1763237f9f12d25cf00735ce63c5655877899.tar.gz
daffm-8cc1763237f9f12d25cf00735ce63c5655877899.zip
Add CmdChain to run commands sequentially in keys
Diffstat (limited to '')
-rw-r--r--lib/Daffm/Action/Commands.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Daffm/Action/Commands.hs b/lib/Daffm/Action/Commands.hs
index a9b706f..a5116eb 100644
--- a/lib/Daffm/Action/Commands.hs
+++ b/lib/Daffm/Action/Commands.hs
@@ -4,13 +4,13 @@
module Daffm.Action.Commands where
import qualified Brick as M
+import Control.Monad (forM_)
import Daffm.Action.Cmdline
import Daffm.Action.Core
import Daffm.Types
import Daffm.Utils (trimStart)
import Data.Bifunctor (Bifunctor (second))
import Data.Char (isSpace)
-import Data.Maybe (fromMaybe)
import qualified Data.Text as Text
runCmdline :: AppEvent ()
@@ -24,8 +24,7 @@ parseCommand (Text.splitAt 2 -> ("!!", cmd)) = Just $ CmdShell True cmd
parseCommand (Text.splitAt 1 -> ("!", cmd)) = Just $ CmdShell False cmd
parseCommand cmd = mkCmd . splitCmdArgs $ trimStart cmd
where
- splitCmdArgs = second trimStart . Text.splitAt cmdEndIdx
- cmdEndIdx = fromMaybe (Text.length cmd) $ Text.findIndex isSpace cmd
+ splitCmdArgs = second trimStart . Text.break isSpace
mkCmd = \case
("q", _) -> Just CmdQuit
("quit", _) -> Just CmdQuit
@@ -57,6 +56,7 @@ processCommand CmdReload = reloadDir
processCommand CmdToggleSelection = toggleCurrentFileSelection
processCommand CmdClearSelection = clearFileSelections
processCommand CmdGoBack = goBackToParentDir
+processCommand (CmdChain chain) = forM_ chain processCommand
processCommand CmdNoop = pure ()
evaluateCommand :: Text.Text -> AppEvent ()