mirror of https://github.com/zachjs/sv2v.git
Add file output write mode
This commit is contained in:
parent
c0cb401abe
commit
5eef44c8f4
|
|
@ -26,6 +26,7 @@ data Exclude
|
|||
data Write
|
||||
= Stdout
|
||||
| Adjacent
|
||||
| File
|
||||
deriving (Show, Typeable, Data, Eq)
|
||||
|
||||
instance Default Write where
|
||||
|
|
@ -66,7 +67,8 @@ defaultJob = Job
|
|||
, verbose = nam "verbose" &= help "Retain certain conversion artifacts"
|
||||
, write = nam_ "write" &= name "w" &= typ "MODE"
|
||||
&= help ("How to write output; default is 'stdout'; use 'adjacent' to"
|
||||
++ " create a .v file next to each input")
|
||||
++ " create a .v file next to each input; use 'file' to create a"
|
||||
++ " sv2v_output.v file")
|
||||
}
|
||||
&= program "sv2v"
|
||||
&= summary ("sv2v " ++ version)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ writeOutput _ [] [] =
|
|||
hPutStrLn stderr "Warning: No input files specified (try `sv2v --help`)"
|
||||
writeOutput Stdout _ asts =
|
||||
hPrint stdout $ concat asts
|
||||
writeOutput File _ asts =
|
||||
writeFile f $ show $ concat asts
|
||||
where f = "sv2v_output.v"
|
||||
writeOutput Adjacent inPaths asts = do
|
||||
outPaths <- mapM rewritePath inPaths
|
||||
badPaths <- filterM doesFileExist outPaths
|
||||
|
|
|
|||
Loading…
Reference in New Issue