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
|
|
|
-
|
|
|
|
- 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
|
|
|
|
2014-10-14 18:20:10 +00:00
|
|
|
cmd :: [Command]
|
|
|
|
cmd = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
2013-04-21 00:24:57 +00:00
|
|
|
command "help" paramNothing seek SectionQuery "display help"]
|
2012-10-13 23:07:56 +00:00
|
|
|
|
fix inversion of control in CommandSeek (no behavior changes)
I've been disliking how the command seek actions were written for some
time, with their inversion of control and ugly workarounds.
The last straw to fix it was sync --content, which didn't fit the
Annex [CommandStart] interface well at all. I have not yet made it take
advantage of the changed interface though.
The crucial change, and probably why I didn't do it this way from the
beginning, is to make each CommandStart action be run with exceptions
caught, and if it fails, increment a failure counter in annex state.
So I finally remove the very first code I wrote for git-annex, which
was before I had exception handling in the Annex monad, and so ran outside
that monad, passing state explicitly as it ran each CommandStart action.
This was a real slog from 1 to 5 am.
Test suite passes.
Memory usage is lower than before, sometimes by a couple of megabytes, and
remains constant, even when running in a large repo, and even when
repeatedly failing and incrementing the error counter. So no accidental
laziness space leaks.
Wall clock speed is identical, even in large repos.
This commit was sponsored by an anonymous bitcoiner.
2014-01-20 08:11:42 +00:00
|
|
|
seek :: CommandSeek
|
|
|
|
seek = withWords 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 ()
|
|
|
|
start' ["options"] = showCommonOptions
|
|
|
|
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:"
|
2012-10-13 23:07:56 +00:00
|
|
|
, unlines $ map cmdline $ concat
|
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
|
|
|
]
|
2013-04-21 00:23:11 +00:00
|
|
|
, "Run 'git-annex' for a complete command list."
|
|
|
|
, "Run 'git-annex command --help' for help on a specific command."
|
|
|
|
, "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
|