file-command-qq 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+82/−4 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- FileCommand: BaseName :: FilePart
- FileCommand: DirName :: FilePart
- FileCommand: Directory :: FilePart
- FileCommand: ECmd :: Cmd -> Expr
- FileCommand: EFilePart :: FilePart -> Expr
- FileCommand: Ext :: FilePart
- FileCommand: FileName :: FilePart
- FileCommand: Parent :: FilePart
- FileCommand: Path :: FilePart
- FileCommand: Root :: FilePart
- FileCommand: data Expr
- FileCommand: data FilePart
- FileCommand: eval :: [Expr] -> Q Exp
- FileCommand: evalExpr :: Name -> Expr -> Q Exp
- FileCommand: evalFilePart :: Name -> FilePart -> Q Exp
- FileCommand: pCmd :: Parser Cmd
- FileCommand: pExpr :: Parser Expr
- FileCommand: pFilePart :: Parser FilePart
- FileCommand: pFilePart' :: Parser FilePart
- FileCommand: parser :: Parser [Expr]
- FileCommand: type Cmd = String
- FileCommand: type Parser = Parsec String ()
Files
- README.md +1/−1
- file-command-qq.cabal +45/−2
- src/FileCommand.hs +36/−1
README.md view
@@ -24,7 +24,7 @@ All "file parts" start with a '$'. The '$' can be escaped by preceding it with a '\' -There are the following options for "file parts"+There are the following options for "file parts" * $path
file-command-qq.cabal view
@@ -2,9 +2,52 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: file-command-qq-version: 0.1.0.0+version: 0.1.0.1 synopsis: Quasiquoter for system commands involving filepaths--- description: +description:+ file-command-qq is a simple quasiquoter for running system commands that take a filepath as an argument.+ .+ For instance+ . + >>> :set -XOverloadedStrings+ >>> import FileCommand+ >>> import Filesystem.Path+ >>> [s|echo $filename|] "/home/test/thing.txt"+ .+ .+ will return+ .+ @+ thing.txt+ ExitSuccess+ @+ .+ You can think of @[s|echo $filename|]@ essentially converts into+ .+ .+ @+ \\path -> system $ "echo" ++ encodeString (filename path)+ @+ .+ Here is another example+ .+ >>> [s|gcc $path -o $directory$basename.o|] "/home/test/thing.c"+ .+ All "file parts" start with a \'$\'. The \'$\' can be escaped by preceding it with a \'\\\'+ .+ There are the following options for "file parts" + .+ .+ * $path+ * $root+ * $directory+ * $parent+ * $filename+ * $dirname+ * $basename+ * $ext+ .+ Which correspond to the respective functions in <https://hackage.haskell.org/package/system-filepath-0.4.6/docs/Filesystem-Path.html#g:1> homepage: https://github.com/jfischoff/file-command-qq license: MIT license-file: LICENSE
src/FileCommand.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE LambdaCase #-}-module FileCommand where+module FileCommand (s) where import Text.Parsec hiding ((<|>), many) import Text.Parsec.Char import Text.Parsec.Combinator@@ -99,6 +99,41 @@ $ extension $(varE filePathName) |] ++-- | A simple quasiquoter for executing system commands on a filepath+-- for example+-- +-- >>> [s|echo $filename|] "/home/test/thing.txt"+-- +-- will return+-- +-- @+-- thing.txt+-- ExitSuccess+-- @+-- +-- You can think of @[s|echo $filename|]@ essentially converts into+-- +-- @+-- \\path -> system $ "echo" ++ encodeString (filename path)+-- @+-- +-- Here is another example+-- +-- >>> [s|gcc $path -o $directory$basename.o|] "/home/test/thing.c"+-- +-- All "file parts" start with a \'$\'. The \'$\' can be escaped by preceding it with a \'\\\'+-- +-- There are the following options for "file parts" +-- +-- * $path+-- * $root+-- * $directory+-- * $parent+-- * $filename+-- * $dirname+-- * $basename+-- * $ext s :: QuasiQuoter s = QuasiQuoter { quoteExp = either (error . show) eval . parse parser ""