yjftp 0.3 → 0.3.1
raw patch · 4 files changed
+37/−13 lines, 4 files
Files
- Network/CommandList.hs +13/−7
- Network/Yjftp.hs +1/−1
- yjftp.cabal +19/−3
- yjftp.hs +4/−2
Network/CommandList.hs view
@@ -21,6 +21,7 @@ , copyFileFTP , editBy , readBy+, getEnv ) where @@ -28,11 +29,12 @@ nlst, dir, pwd, cwd, rename, delete, mkdir, rmdir) import System.IO (Handle, hClose, hPutStr) import System.Directory (setCurrentDirectory, removeFile, getTemporaryDirectory)+import System.Environment (getEnv) import System.Cmd (system)+import System.IO.Error (isUserError) import System.Posix.Temp (mkstemp) import Data.Maybe (fromJust) import Control.Exception (catchJust, ioErrors, ioError, bracketOnError)-import System.IO.Error (isUserError) type Action = FTPConnection -> [String] -> IO Bool type CommandList = [(String, Action)]@@ -59,8 +61,10 @@ , ("rmdir", removeDirectoryFTP) , ("mv", moveFileFTP) , ("cp", copyFileFTP)- , ("vi", editBy ("vi "++))- , ("view", readBy ("view "++))+ , ("edit", editBy $ \fn -> do edt <- catch (getEnv "EDITOR") (const $ return "vi")+ return $ edt ++ " " ++ fn)+ , ("show", readBy $ \fn -> do pgr <- catch (getEnv "PAGER") (const $ return "less")+ return $ pgr ++ " " ++ fn) ] const2 :: a -> b -> c -> a@@ -130,27 +134,29 @@ copyFileFTP h [src, dst] = getbinary h src >>= putbinary h dst . fst >> return True copyFileFTP _ _ = error "Usage: cp src dist" -editBy :: (String -> String) -> Action+editBy :: (String -> IO String) -> Action editBy mkEdtr h [fp] = bracketOnError (mkTempFile $ "ftpvi_" ++ basename fp) (\(fn, fd) -> hClose fd >> tmpFileSave fn) $ \(fn, fd) -> do catchJust ioErrors (getbinary h fp >>= hPutStr fd . fst) (\err -> if isUserError err then return () else ioError err) hClose fd- system $ mkEdtr fn+ edt <- mkEdtr fn+ system edt readFile fn >>= putbinary h fp removeFile fn return True where tmpFileSave n = putStrLn $ "temp file save as " ++ "'" ++ n ++ "'" editBy _ _ _ = error "editBy: bad args" -readBy :: (String -> String) -> Action+readBy :: (String -> IO String) -> Action readBy vwr h [fp] = bracketOnError (mkTempFile $ "ftpview_" ++ basename fp) (\(fn, fd) -> hClose fd >> removeFile fn) $ \(fn, fd) -> do getbinary h fp >>= hPutStr fd . fst hClose fd- system $ vwr fn+ pgr <- vwr fn+ system pgr removeFile fn return True readBy _ _ _ = error "readBy: bad arguments"
Network/Yjftp.hs view
@@ -179,5 +179,5 @@ | isSpace c = myWords cs | isSym c = takeWhile isSym str : myWords (dropWhile isSym str) | otherwise = error "myWords: maybe your input is not askii"- where isWord c_ = isAlphaNum c_ || c_ == '_'+ where isWord c_ = isAlphaNum c_ || elem c_ [ '_', '.', '/' ] isSym c_ = isAscii c_ && not (isAlphaNum c_) && not (isSpace c_)
yjftp.cabal view
@@ -1,13 +1,29 @@ Name: yjftp-Version: 0.3+Version: 0.3.1 License: GPL License-file: LICENSE Author: Yoshikuni Jujo Maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp> Category: Network Synopsis: CUI FTP client like 'ftp', 'ncftp'-Description: FTP client- Just CUI FTP client+Description: Just CUI FTP client.+ .+ If no arguments, then it ask server address, user name and password.+ .+ If only argument server address are given, then it try login as anonymous user.+ .+ If argument server address and user name, then it ask password.+ .+ And password can give by '-p [passwd]' from command line.+ .+ Once login, you can run command 'ls', 'cd', 'cat', 'put', 'get', 'edit', 'show'+ and so on.+ .+ And you can put/get immediately by doing following.+ .+ > yjftp put filepath srvr.address/directorypath [user_name] [-p password]+ .+ > yjftp get srvr.address/filepath [user_name] [-p password] Stability: experimental Homepage: http://homepage3.nifty.com/salamander/second/projects/yjftp/index.xhtml Package-Url: http://homepage3.nifty.com/salamander/second/portage/distfiles/yjftp-0.3.tar.gz
yjftp.hs view
@@ -24,8 +24,10 @@ , ("rmdir", removeDirectoryFTP) , ("mv", moveFileFTP) , ("cp", copyFileFTP)- , ("vi", editBy ("vi "++))- , ("view", readBy ("view "++))+ , ("edit", editBy $ \fn -> do edt <- catch (getEnv "EDITOR") (const $ return "vi")+ return $ edt ++ " " ++ fn)+ , ("show", readBy $ \fn -> do pgr <- catch (getEnv "PAGER") (const $ return "less")+ return $ pgr ++ " " ++ fn) ] main :: IO ()