git-annex/Command/Help.hs

77 lines
1.9 KiB
Haskell
Raw Normal View History

2012-10-13 23:07:56 +00:00
{- git-annex command
-
- Copyright 2012 Joey Hess <id@joeyh.name>
2012-10-13 23:07:56 +00:00
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Help where
import Common.Annex
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
import System.Console.GetOpt
2012-10-13 23:07:56 +00:00
cmd :: Command
cmd = noCommit $ noRepo startNoRepo $ dontCheck repoExists $
command "help" SectionCommon "display help"
"COMMAND" (withParams seek)
2012-10-13 23:07:56 +00:00
seek :: CmdParams -> CommandSeek
seek = withWords start
2012-10-13 23:07:56 +00:00
start :: [String] -> CommandStart
start params = do
liftIO $ start' params
2012-10-13 23:07:56 +00:00
stop
startNoRepo :: CmdParams -> IO ()
startNoRepo = start'
start' :: [String] -> IO ()
start' ["options"] = showCommonOptions
start' [c] = showGitHelp c
start' _ = showGeneralHelp
2013-03-27 17:51:24 +00:00
showCommonOptions :: IO ()
2014-01-26 20:25:55 +00:00
showCommonOptions = putStrLn $ usageInfo "Common options:" gitAnnexOptions
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:"
, unlines $ map cmdline $
[ 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
]
2013-04-21 00:23:11 +00:00
, "Run 'git-annex' for a complete command list."
, "Run 'git-annex help command' for help on a specific command."
2013-04-21 00:23:11 +00:00
, "Run `git annex help options' for a list of common options."
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
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 ++ "/"