Skip to content

Commit

Permalink
Added replaying of captured positions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitar committed Sep 26, 2010
1 parent 0c64077 commit 6e4c30b
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/UploadFile.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,18 +2,45 @@ module UploadFile where


import Control.Exception import Control.Exception
import Control.Monad.State import Control.Monad.State
import System.Console.GetOpt
import System.Environment import System.Environment
import System.Exit
import System.IO import System.IO
import System.FilePath import System.FilePath


import NXT.NXT import NXT.NXT
import NXT.Data import NXT.Data
import NXT.Types import NXT.Types


data Option = Help deriving (Eq,Show)

options :: [OptDescr Option]
options = [
Option ['h'] ["help"] (NoArg Help) "show this help"
]

upload :: IO () upload :: IO ()
upload = do upload = do
programName <- getProgName
let header = programName ++ " [option ...] <file ...>" ++ "\n\nOptions:"
usage = "Usage:\n" ++ (usageInfo header options)

args <- getArgs args <- getArgs
bracket initialize terminate (evalStateT (uploadFiles args)) (opts, files) <- case getOpt Permute options args of
(o, fs, []) -> return (o, fs)
(_, _, errs) -> do
hPutStrLn stderr $ "Error(s):\n" ++ concat errs ++ "\n" ++ usage
exitWith $ ExitFailure 1

when (Help `elem` opts) $ do
putStrLn usage
exitWith ExitSuccess

when (null files) $ do
hPutStrLn stderr $ "Error(s):\nno files to upload specified\n" ++ "\n" ++ usage
exitWith $ ExitFailure 1

bracket initialize terminate (evalStateT (uploadFiles files))


uploadFiles :: [String] -> NXT () uploadFiles :: [String] -> NXT ()
uploadFiles args = do uploadFiles args = do
Expand Down

0 comments on commit 6e4c30b

Please sign in to comment.