madlang 3.1.0.0 → 3.1.0.1
raw patch · 2 files changed
+17/−2 lines, 2 filesdep −lens
Dependencies removed: lens
Files
- madlang.cabal +1/−2
- src/Text/Madlibs/Exec/Main.hs +16/−0
madlang.cabal view
@@ -1,5 +1,5 @@ name: madlang-version: 3.1.0.0+version: 3.1.0.1 synopsis: Randomized templating language DSL description: Madlang is a text templating language written in Haskell, meant to explore computational creativity and generative@@ -70,7 +70,6 @@ , random-shuffle , mtl , ansi-wl-pprint- , lens , containers , titlecase , th-lift-instances
src/Text/Madlibs/Exec/Main.hs view
@@ -24,6 +24,7 @@ data Subcommand = Debug { input :: FilePath } | Run { _rep :: Maybe Int , clInputs :: [String] , input :: FilePath } | Lint { clInputs :: [String] , input :: FilePath }+ | Sample { clInputs :: [String], input :: FilePath } | Install | VimInstall @@ -34,6 +35,7 @@ (command "run" (info temp (progDesc "Generate text from a .mad file")) <> command "tree" (info debug (progDesc "Display a tree with all possible paths")) <> command "check" (info lint (progDesc "Check a file"))+ <> command "sample" (info sample (progDesc "Sample a template by generating text many times.")) <> command "install" (info (pure Install) (progDesc "Install/update prebundled libraries.")) <> command "vim" (info (pure VimInstall) (progDesc "Install vim plugin.")) ))@@ -55,6 +57,18 @@ <> completer (bashCompleter "file -X '!*.mad' -o plusdirs") <> help "File path to madlang template")) +-- | Parser for the sample subcommand+sample :: Parser Subcommand+sample = Sample+ <$> (many $ strOption+ (short 'i'+ <> metavar "VAR"+ <> help "command-line inputs to the template."))+ <*> (argument str+ (metavar "FILEPATH"+ <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")+ <> help "File path to madlang template"))+ debug :: Parser Subcommand debug = Debug <$> (argument str@@ -107,6 +121,8 @@ case sub rec of (Run reps _ _) -> replicateM_ (fromMaybe 1 reps) $ runFile ins filepath >>= TIO.putStrLn+ (Sample _ _) ->+ replicateM_ 60 $ runFile ins filepath >>= TIO.putStrLn (Debug _) -> putStr . (either show displayTree) =<< makeTree ins "" filepath (Lint _ _) -> do parsed <- parseFile ins "" filepath