madlang 4.0.2.1 → 4.0.2.2
raw patch · 5 files changed
+25/−24 lines, 5 files
Files
- README.md +1/−1
- app/Main.hs +19/−19
- cabal.project.local +3/−1
- madlang.cabal +1/−1
- src/Text/Madlibs/Ana/Parse.hs +1/−2
README.md view
@@ -28,7 +28,7 @@ ```bash $ cabal update- $ cabal new-install madlang --symlink-bindir ~/.local/bin+ $ cabal new-install madlang ``` You may need to add `$HOME/.local/bin` to your `PATH`. To do so:
app/Main.hs view
@@ -28,7 +28,7 @@ -- | Parser for command-line options for the program orders :: Parser Program orders = Program- <$> (hsubparser+ <$> hsubparser (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"))@@ -36,57 +36,57 @@ <> command "install" (info (pure Install) (progDesc "Install/update prebundled libraries.")) <> command "get" (info fetch (progDesc "Sample a template by generating text many times.")) <> command "vim" (info (pure VimInstall) (progDesc "Install vim plugin."))- ))+ ) -- | Parser for the run subcommand temp :: Parser Subcommand temp = Run- <$> (optional $ read <$> strOption+ <$> optional (read <$> strOption (long "rep" <> short 'r' <> metavar "REPETITIONS" <> help "Number of times to repeat"))- <*> (argument str+ <*> argument str (metavar "FILEPATH" <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")- <> help "File path to madlang template"))+ <> help "File path to madlang template") -- | Parser for the sample subcommand sample :: Parser Subcommand sample = Sample- <$> (many $ strOption+ <$> many (strOption (short 'i' <> metavar "VAR" <> help "command-line inputs to the template."))- <*> (argument str+ <*> argument str (metavar "FILEPATH" <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")- <> help "File path to madlang template"))+ <> help "File path to madlang template") fetch :: Parser Subcommand fetch = Get- <$> (argument str+ <$> argument str (metavar "REPOSITORY"- <> help "Repository to fetch, e.g. vmchale/some-library"))+ <> help "Repository to fetch, e.g. vmchale/some-library") debug :: Parser Subcommand debug = Debug- <$> (argument str+ <$> argument str (metavar "FILEPATH" <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")- <> help "File path to madlang template"))+ <> help "File path to madlang template") -- | Parser for the lint subcommand lint :: Parser Subcommand lint = Lint- <$> (many $ strOption+ <$> many (strOption (short 'i' <> metavar "VAR" <> help "command-line inputs to the template."))- <*> (argument str+ <*> argument str (metavar "FILEPATH" <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")- <> help "File path to madlang template"))+ <> help "File path to madlang template") -- | Main program action --@@ -105,7 +105,7 @@ wrapper = info (helper <*> versionInfo <*> orders) (fullDesc <> progDesc "Madlang templating language. For more detailed help, use 'man madlang'"- <> header ("Madlang - templating text made easy"))+ <> header "Madlang - templating text made easy") -- | given a parsed record perform the appropriate IO action template :: Program -> IO ()@@ -117,15 +117,15 @@ _ -> do let toFolder = input . sub $ rec if getDir toFolder == "" then pure () else setCurrentDirectory (getDir toFolder)- let filepath = reverse . (takeWhile (/='/')) . reverse $ toFolder+ let filepath = reverse . takeWhile (/='/') . reverse $ toFolder let ins = map T.pack (clInputs . sub $ rec) case sub rec of (Run reps _) -> (TL.init . TL.unlines . fmap TL.fromStrict <$> runFileN (fromMaybe 1 reps) ins filepath) >>= TLIO.putStrLn (Sample _ _) -> (TL.init . TL.unlines . fmap TL.fromStrict <$> runFileN 60 ins filepath) >>= TLIO.putStrLn- (Debug _) -> putStr . (either show displayTree) =<< makeTree ins "" filepath+ (Debug _) -> putStr . either show displayTree =<< makeTree ins "" filepath (Lint _ _) -> do parsed <- parseFile ins "" filepath- putStrLn $ either (parseErrorPretty) (const "No syntax errors found.") parsed+ putStrLn $ either parseErrorPretty (const "No syntax errors found.") parsed _ -> pure ()
cabal.project.local view
@@ -1,2 +1,4 @@-optimization: 1+tests: true+benchmarks: true+documentation: true constraints: madlang +development
madlang.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: madlang-version: 4.0.2.1+version: 4.0.2.2 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2016-2018 Vanessa McHale
src/Text/Madlibs/Ana/Parse.hs view
@@ -178,8 +178,7 @@ final :: [T.Text] -> Parser [(Prob, [PreTok])] final ins = do main- val <- fmap normalize . some $ pair ins- pure val+ fmap normalize . some $ pair ins -- | Parse the program in terms of `PreTok` and the `Key`s to link them. program :: [T.Text] -> Parser [(Key, [(Prob, [PreTok])])]