Permalink
Browse files

Added replaying of captured positions.

  • Loading branch information...
1 parent 0c64077 commit 6e4c30b4a2bd1900705e0374cc1ec9fb66e008bf @mitar committed Sep 26, 2010
Showing with 28 additions and 1 deletion.
  1. +28 −1 src/UploadFile.hs
View
@@ -2,18 +2,45 @@ module UploadFile where
import Control.Exception
import Control.Monad.State
+import System.Console.GetOpt
import System.Environment
+import System.Exit
import System.IO
import System.FilePath
import NXT.NXT
import NXT.Data
import NXT.Types
+data Option = Help deriving (Eq,Show)
+
+options :: [OptDescr Option]
+options = [
+ Option ['h'] ["help"] (NoArg Help) "show this help"
+ ]
+
upload :: IO ()
upload = do
+ programName <- getProgName
+ let header = programName ++ " [option ...] <file ...>" ++ "\n\nOptions:"
+ usage = "Usage:\n" ++ (usageInfo header options)
+
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 args = do

0 comments on commit 6e4c30b

Please sign in to comment.