Skip to content
Snippets Groups Projects
Commit 9c02d734 authored by Jens Nolte's avatar Jens Nolte
Browse files

Fix cli: swap 'script' and 'script --persistent'

parent 4d6a375c
No related branches found
No related tags found
No related merge requests found
......@@ -26,11 +26,11 @@ scriptBlock path = forever $ updateBlock =<< (lift blockScriptAction)
-- I am trying to replace i3blocks scripts with native haskell blocks, so I do not need it
(exitCode, output) <- liftIO $ readProcessStdout $ shell path
return $ case exitCode of
ExitSuccess -> createScriptBlock output
ExitSuccess -> createScriptBlockOutput output
(ExitFailure nr) -> case nr of
_ -> mkErrorOutput $ "exit code " <> T.pack (show nr) <> ""
createScriptBlock :: C8.ByteString -> BlockOutput
createScriptBlock output = case map E.decodeUtf8 (C8.lines output) of
createScriptBlockOutput :: C8.ByteString -> BlockOutput
createScriptBlockOutput output = case map E.decodeUtf8 (C8.lines output) of
(text:short:_) -> parseTags'' text short
(text:_) -> parseTags' text
[] -> emptyBlock
......
......@@ -85,4 +85,4 @@ scriptBlockParser :: Parser (BarIO ())
scriptBlockParser = helper <*> do
persistent <- switch $ long "persistent" <> short 'p' <> help "Run script in persistent mode (every line of output updates the block)."
script <- strArgument (metavar "SCRIPT" <> help "The script that will be executed with a shell.")
return $ (if persistent then addBlock . scriptBlock else addBlock . persistentScriptBlock) script
return $ (if persistent then addBlock . persistentScriptBlock else addBlock . scriptBlock) script
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment