diff --git a/.gitignore b/.gitignore index facfe4c..f90ea4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .stack-work +stack.yaml.lock *# \#* *~ diff --git a/CHANGES.md b/CHANGES.md index e7754f9..856fbf0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +0.1.7 +========== +* Switch "script" output interpreter from "sh" to "/bin/env sh". +* Update universum and orgmode-parse version (includes + https://github.com/ixmatus/orgmode-parse/pull/53) + 0.1.6 ========== * Support "or" tags -- now it's possible to specify "t1 | t2 | t3" as a modifier by diff --git a/orgstat.cabal b/orgstat.cabal index 4d9d4a7..3eae892 100644 --- a/orgstat.cabal +++ b/orgstat.cabal @@ -1,5 +1,5 @@ name: orgstat -version: 0.1.6 +version: 0.1.7 synopsis: Statistics visualizer for org-mode license: GPL-3 license-file: LICENSE @@ -50,12 +50,12 @@ library , lens >= 4.14 , mtl >= 2.2.1 , optparse-simple - , orgmode-parse >= 0.2.1 && < 0.3 + , orgmode-parse >= 0.2.3 && < 0.3 , process >= 1.6.3.0 , text >= 1.2.2.1 , time >= 1.6.0.1 , turtle >= 1.2.8 - , universum >= 1.4.0 + , universum >= 1.5.0 , yaml >= 0.8.21.1 hs-source-dirs: src default-language: Haskell2010 diff --git a/src/OrgStat/Config.hs b/src/OrgStat/Config.hs index 7a036b6..147f0e1 100644 --- a/src/OrgStat/Config.hs +++ b/src/OrgStat/Config.hs @@ -45,8 +45,8 @@ data ConfDate data ConfRange = ConfFromTo !ConfDate !ConfDate - | ConfBlockWeek !Integer | ConfBlockDay !Integer + | ConfBlockWeek !Integer | ConfBlockMonth !Integer deriving (Show) @@ -159,7 +159,8 @@ instance FromJSON ConfOutputType where fmap Left (o .: "scriptPath") <|> fmap Right (o .: "inline") spReports <- o .: "reports" - pure $ ScriptOutput $ ScriptParams spScript spReports + spInterpreter <- o .:? "interpreter" .!= "sh" + pure $ ScriptOutput $ ScriptParams spScript spReports spInterpreter (String "block") -> do boReport <- o .: "report" _bpMaxLength <- o .:? "maxLength" .!= 80 diff --git a/src/OrgStat/Outputs/Script.hs b/src/OrgStat/Outputs/Script.hs index 80299c5..7cb9caa 100644 --- a/src/OrgStat/Outputs/Script.hs +++ b/src/OrgStat/Outputs/Script.hs @@ -15,6 +15,7 @@ import System.Process (callCommand) import OrgStat.Ast (filterHasClock, orgTotalDuration) import OrgStat.Config (confReports, crName) import OrgStat.Helpers (resolveReport) +import OrgStat.Logging import OrgStat.Outputs.Types (ScriptParams (..)) import OrgStat.Util (timeF) import OrgStat.WorkMonad (WorkM, wcConfig) @@ -31,6 +32,7 @@ processScriptOutput ScriptParams{..} = do -- Set env variables prevVars <- forM allReports $ \(toString -> reportName,org) -> do let duration = timeF $ orgTotalDuration $ filterHasClock org + logDebug $ "Variable " <> show reportName <> " duration is " <> show duration (prevVar :: Maybe String) <- liftIO $ lookupEnv reportName liftIO $ setEnv reportName (toString duration) pure $ (reportName,) <$> prevVar @@ -40,7 +42,8 @@ processScriptOutput ScriptParams{..} = do -- Execute script let cmdArgument = either id (\t -> "-c \"" <> toString t <> "\"") spScript liftIO $ callCommand $ - "sh " <> cmdArgument + spInterpreter <> " " <> cmdArgument + --"/bin/env sh " <> cmdArgument -- Restore the old variables, clean new. forM_ (map fst allReports) $ \(toString -> reportName) -> do diff --git a/src/OrgStat/Outputs/Types.hs b/src/OrgStat/Outputs/Types.hs index 818dff1..500c133 100644 --- a/src/OrgStat/Outputs/Types.hs +++ b/src/OrgStat/Outputs/Types.hs @@ -23,13 +23,13 @@ module OrgStat.Outputs.Types , BlockOutput (..) ) where -import Universum +import Universum -import Control.Lens (makeLenses) +import Control.Lens (makeLenses) -import Data.Default (Default (..)) -import Diagrams.Backend.SVG (B) -import qualified Diagrams.Prelude as D +import Data.Default (Default (..)) +import Diagrams.Backend.SVG (B) +import qualified Diagrams.Prelude as D ---------------------------------------------------------------------------- -- Timeline @@ -75,10 +75,12 @@ newtype SummaryOutput = SummaryOutput Text -- | Parameters of the summary output data ScriptParams = ScriptParams - { spScript :: !(Either FilePath Text) + { spScript :: !(Either FilePath Text) -- ^ Either path to the script to execute, or a script text itself. - , spReports :: ![Text] + , spReports :: ![Text] -- ^ Reports to consider. + , spInterpreter :: !String + -- ^ Interpreter to use. } deriving Show ---------------------------------------------------------------------------- diff --git a/stack.yaml b/stack.yaml index 5ebf56b..fc8b319 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,7 +5,7 @@ nix: extra-deps: - fmt-0.6 -- universum-1.4.0 -- orgmode-parse-0.2.2 +- universum-1.5.0 +- orgmode-parse-0.2.3 - thyme-0.3.5.5 # required by orgmode-parse