madlang 2.4.1.5 → 2.4.1.6
raw patch · 3 files changed
+51/−4 lines, 3 filesdep ~basesetup-changed
Dependency ranges changed: base
Files
- Setup.hs +42/−2
- madlang.cabal +8/−1
- src/Text/Madlibs/Exec/Main.hs +1/−1
Setup.hs view
@@ -1,12 +1,52 @@+{-# LANGUAGE TemplateHaskell #-}++import Control.Monad (unless, void)+import Data.FileEmbed (embedStringFile)+import Data.Maybe import Distribution.Simple+import System.Directory (createDirectoryIfMissing) import System.Environment (lookupEnv)+import System.Process (readCreateProcessWithExitCode, shell) -main = writeBashCompletions >> defaultMain+manpage :: String+manpage = $(embedStringFile "man/madlang.1") +main :: IO ()+main = setManpath >>+ writeManpages >>+ writeBashCompletions >>+ defaultMain++setManpath :: IO ()+setManpath = do+ home <- lookupEnv "HOME"+ case home of+ Just x -> do+ let bashRc = x ++ "/.bashrc"+ config <- readFile bashRc+ unless ("#manpath updated by madlang" `elem` lines config)+ (appendFile bashRc "\n#manpath updated by madlang\nexport MANPATH=~/.local/share:$MANPATH\n" >>+ void (readCreateProcessWithExitCode (shell "MANPATH=~/.local/share:$MANPATH mandb") ""))+ Nothing -> pure ()++writeManpages :: IO ()+writeManpages = do+ home <- lookupEnv "HOME"+ case home of+ Just x -> do+ let manPath = x ++ "/.local/share/man/man1"+ createDirectoryIfMissing True manPath+ writeFile (manPath ++ "/madlang.1") manpage+ Nothing -> pure ()+ -- TODO only write if we can't find our own thing! writeBashCompletions :: IO () writeBashCompletions = do home <- lookupEnv "HOME" case home of- Just x -> appendFile (x ++ "/.bashrc") "\n# Added by madlang\neval \"$(madlang --bash-completion-script madlang)\"\n"+ Just x -> do+ let bashRc = x ++ "/.bashrc"+ config <- readFile bashRc+ unless ("# Added by madlang" `elem` lines config)+ (appendFile bashRc "\n# Added by madlang\neval \"$(madlang --bash-completion-script madlang)\"\n") Nothing -> pure ()
madlang.cabal view
@@ -1,5 +1,5 @@ name: madlang-version: 2.4.1.5+version: 2.4.1.6 synopsis: Randomized templating language DSL description: Madlang is a text templating language written in Haskell, meant to explore computational creativity and generative@@ -21,6 +21,13 @@ , cabal.project.local , man/madlang.1 cabal-version: >=1.10++custom-setup+ setup-depends: base+ , Cabal+ , file-embed+ , directory+ , process Flag development { Description: Turn on '-Werror'
src/Text/Madlibs/Exec/Main.hs view
@@ -33,7 +33,7 @@ (command "run" (info temp (progDesc "Generate text from a .mad file")) <> command "debug" (info debug (progDesc "Debug a template")) <> command "lint" (info lint (progDesc "Lint a file"))- <> command "install" (info (pure Install) (progDesc "Install shell completions for bash and manpages"))+ <> command "install" (info (pure Install) (progDesc "Install/update prebundled libraries.")) )) -- | Parser for the run subcommand