Permalink
Browse files

add --dest commandline option

  • Loading branch information...
1 parent 132fc96 commit adbab88fafc008eda45c4ecdc33da01677f6a185 @wavewave committed Dec 27, 2011
@@ -7,6 +7,6 @@ commandLineProcess :: Xournal_convert -> IO ()
commandLineProcess Test = do
putStrLn "test called"
startJob
-commandLineProcess (MakeSVG fname) = do
+commandLineProcess (MakeSVG fname mdest) = do
putStrLn "makeSVG is called"
- startMakeSVG fname
+ startMakeSVG fname mdest
@@ -13,6 +13,7 @@ import Data.Xournal.Predefined
import Text.StringTemplate
import Text.StringTemplate.Helpers
+import System.Directory
import System.FilePath
import System.IO
@@ -23,10 +24,14 @@ startJob = do
putStrLn "job started"
-startMakeSVG :: FilePath -> IO ()
-startMakeSVG fname = do
+startMakeSVG :: FilePath -> Maybe FilePath -> IO ()
+startMakeSVG fname mdest = do
xojcontent <- read_xournal fname
+ case mdest of
+ Nothing -> return ()
+ Just dest -> setCurrentDirectory dest
+
let (fname_wo_ext,fname_ext) = splitExtension fname
let pages = xoj_pages xojcontent
names = map (\x -> fname_wo_ext ++ show x ++ ".svg") [1..]
@@ -6,6 +6,7 @@ import System.Console.CmdArgs
data Xournal_convert = Test
| MakeSVG { xojfile :: FilePath
+ , dest :: Maybe FilePath
}
deriving (Show,Data,Typeable)
@@ -14,6 +15,7 @@ test = Test
makeSVG :: Xournal_convert
makeSVG = MakeSVG { xojfile = "test.xoj" &= typ "FILENAME" &= argPos 0
+ , dest = Nothing &= typ "DESTINATION"
}

0 comments on commit adbab88

Please sign in to comment.