FTPLine 1.0.1 → 1.0.2
raw patch · 2 files changed
+18/−15 lines, 2 filesdep +deepseq
Dependencies added: deepseq
Files
- FTPLine.cabal +10/−5
- Main.hs +8/−10
FTPLine.cabal view
@@ -1,5 +1,5 @@ Name: FTPLine -Version: 1.0.1 +Version: 1.0.2 Cabal-Version: >= 1.6 License: BSD3 License-file: license @@ -8,15 +8,19 @@ Homepage: http://ddiaz.asofilak.es/packages/FTPLine Category: Network Synopsis: A command-line FTP client. -Description: A command-line FTP client. Type @help@ for a list of commands. +Description: A command-line FTP client. Type @help@ for a list of commands. Online documentation at the homepage. . Changes from last version: . - * Added a restriction in the haskeline version. + * Now, FTPLine shows a correct version number. . - * Added the type synonym @FTPState@. + * Changed @handres@ error handling. . - * Removed unused function @addNChar@. + * Added error handling to @curdir@ operation. + . + * Removed @underline@ function (It didn't has any effect). + . + * A little change on the welcome message. Build-Type: Simple Executable FTPLine @@ -28,5 +32,6 @@ , network , haskeline >=0.6.2.4 && < 0.7 , ansi-terminal + , deepseq Extensions: FlexibleInstances Main-is: Main.hs
Main.hs view
@@ -46,7 +46,7 @@ getting f = f <$> lift get modif :: (MonadTrans t, MonadState s m) => (s -> s) -> t m () -modif f = lift $ modify f +modif = lift . modify getConnection :: FTPLine (Maybe FTPConnection) getConnection = getting fst3 @@ -61,10 +61,10 @@ getFile = getting snd3 newFile :: File -> FTPLine () -newFile f = modif $ \(mc,mf,md) -> (mc,Just f,md) +newFile f = modif $ \(mc,_,md) -> (mc,Just f,md) cleanFile :: FTPLine () -cleanFile = modif $ \(mc,mf,md) -> (mc,Nothing,md) +cleanFile = modif $ \(mc,_,md) -> (mc,Nothing,md) getHost :: FTPLine String getHost = getting (maybe "Local" id . thr3) @@ -212,7 +212,7 @@ xs = args str handres :: Show a => FTPLine a -> FTPLine () -handres c = hand ((>> fail "No command result.") . withColor Red . output) c >>= output +handres c = hand ((>> (liftIO $ fail "No command result.")) . withColor Red . output) c >>= output hand_ :: FTPLine () -> FTPLine () hand_ = hand (withColor Red . output) @@ -220,6 +220,7 @@ printHelp :: String -> FTPLine () printHelp str = withColor Cyan $ mapM_ (\ln -> if head ln == '*' then outputStrLn ln else italized $ outputStrLn ln ) $ commandDesc str + runCom :: String -> [String] -> FTPLine () runCom str ["help"] = printHelp str runCom "help" _ = mapM_ printHelp commands @@ -358,15 +359,12 @@ italized :: MonadIO m => m a -> m a italized = withSGR [ SetSwapForegroundBackground True ] [ SetSwapForegroundBackground False ] -underline :: MonadIO m => m a -> m a -underline = withSGR [ SetUnderlining SingleUnderline ] [ SetUnderlining NoUnderline ] - -- Main main = do setSGR [ SetColor Foreground Vivid White ] -- args <- getArgs - underline $ putStrLn "Welcome to FTPLine 1.0.0." + putStrLn "*** Welcome to FTPLine 1.0.2 ***" if null args then do withColor Cyan $ do putStr "Type " italized $ putStr "help" putStrLn " for a list of commands." @@ -389,7 +387,8 @@ else withColor Red $ putStrLn $ "File " ++ arg ++ " doesn't exist." setSGR [ Reset ] -mainCicle = do (mcd,hn) <- withColor Green $ do mcd <- fst <$> curdir +mainCicle = do (mcd,hn) <- withColor Green $ do mcd <- hand (\e -> do withColor Red $ output e + return Nothing ) $ fst <$> curdir hn <- getHost return (mcd,hn) let cd = if isNothing mcd then "? " else fromJust mcd @@ -404,7 +403,6 @@ exit = do hand (\_ -> return failure) $ withColor Green disconnect outputStrLn "Closing FTPLine." -