summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Network/CommandList.hs20
-rw-r--r--Network/Yjftp.hs2
-rw-r--r--yjftp.cabal22
-rw-r--r--yjftp.hs6
4 files changed, 37 insertions, 13 deletions
diff --git a/Network/CommandList.hs b/Network/CommandList.hs
index b3d7b88..22318c4 100644
--- a/Network/CommandList.hs
+++ b/Network/CommandList.hs
@@ -21,6 +21,7 @@ module Network.CommandList (
, copyFileFTP
, editBy
, readBy
+, getEnv
) where
@@ -28,11 +29,12 @@ import Network.FTP.Client (FTPConnection, getbinary, putbinary, uploadbinary,
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 @@ defaultCommandList = [
, ("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 :: Action
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"
diff --git a/Network/Yjftp.hs b/Network/Yjftp.hs
index 247ab15..9f21557 100644
--- a/Network/Yjftp.hs
+++ b/Network/Yjftp.hs
@@ -179,5 +179,5 @@ myWords str@(c:cs)
| 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_)
diff --git a/yjftp.cabal b/yjftp.cabal
index 52f34ef..4c6fdb3 100644
--- a/yjftp.cabal
+++ b/yjftp.cabal
@@ -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
diff --git a/yjftp.hs b/yjftp.hs
index b00d7b1..065b3c3 100644
--- a/yjftp.hs
+++ b/yjftp.hs
@@ -24,8 +24,10 @@ myCommandList = [
, ("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 ()