2012-10-13 23:07:56 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2012-10-13 23:07:56 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2012-10-13 23:07:56 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Help where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Command.Init
|
|
|
|
import qualified Command.Add
|
|
|
|
import qualified Command.Drop
|
|
|
|
import qualified Command.Get
|
|
|
|
import qualified Command.Move
|
|
|
|
import qualified Command.Copy
|
|
|
|
import qualified Command.Sync
|
|
|
|
import qualified Command.Whereis
|
|
|
|
import qualified Command.Fsck
|
2013-03-27 17:51:24 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-08 19:39:05 +00:00
|
|
|
cmd = noCommit $ dontCheck repoExists $
|
|
|
|
noRepo (parseparams startNoRepo) $
|
|
|
|
command "help" SectionCommon "display help"
|
|
|
|
"COMMAND" (parseparams seek)
|
|
|
|
where
|
|
|
|
parseparams = withParams
|
2012-10-13 23:07:56 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withWords (commandAction . start)
|
2012-10-13 23:07:56 +00:00
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
2013-11-30 19:18:40 +00:00
|
|
|
start params = do
|
|
|
|
liftIO $ start' params
|
2012-10-13 23:07:56 +00:00
|
|
|
stop
|
|
|
|
|
2013-11-30 19:18:40 +00:00
|
|
|
startNoRepo :: CmdParams -> IO ()
|
|
|
|
startNoRepo = start'
|
|
|
|
|
|
|
|
start' :: [String] -> IO ()
|
2015-03-23 21:35:39 +00:00
|
|
|
start' [c] = showGitHelp c
|
2013-11-30 19:18:40 +00:00
|
|
|
start' _ = showGeneralHelp
|
|
|
|
|
2013-03-27 17:51:24 +00:00
|
|
|
showGeneralHelp :: IO ()
|
|
|
|
showGeneralHelp = putStrLn $ unlines
|
2013-04-21 00:23:11 +00:00
|
|
|
[ "The most frequently used git-annex commands are:"
|
2015-07-08 19:08:02 +00:00
|
|
|
, unlines $ map cmdline $
|
2014-10-14 18:20:10 +00:00
|
|
|
[ Command.Init.cmd
|
|
|
|
, Command.Add.cmd
|
|
|
|
, Command.Drop.cmd
|
|
|
|
, Command.Get.cmd
|
|
|
|
, Command.Move.cmd
|
|
|
|
, Command.Copy.cmd
|
|
|
|
, Command.Sync.cmd
|
|
|
|
, Command.Whereis.cmd
|
|
|
|
, Command.Fsck.cmd
|
2012-10-13 23:07:56 +00:00
|
|
|
]
|
2015-07-09 15:49:52 +00:00
|
|
|
, "For a complete command list, run: git-annex"
|
|
|
|
, "For help on a specific command, run: git-annex help COMMAND"
|
2012-10-13 23:07:56 +00:00
|
|
|
]
|
2012-11-12 05:05:04 +00:00
|
|
|
where
|
|
|
|
cmdline c = "\t" ++ cmdname c ++ "\t" ++ cmddesc c
|
2015-03-23 21:35:39 +00:00
|
|
|
|
|
|
|
showGitHelp :: String -> IO ()
|
|
|
|
showGitHelp c =
|
|
|
|
unlessM (githelp) $
|
|
|
|
putStrLn $ "View online help at " ++ url
|
|
|
|
where
|
|
|
|
githelp = boolSystem "git" [Param "help", Param fullc]
|
|
|
|
fullc = "git-annex-" ++ c
|
|
|
|
url = "https://git-annex.branchable.com/" ++ fullc ++ "/"
|