Make full option parsing be done when not in a git repo, so --help can be displayed for commands that require a git repo, etc.
This commit is contained in:
parent
08b7af3fe6
commit
f6c03414cf
3 changed files with 23 additions and 9 deletions
25
CmdLine.hs
25
CmdLine.hs
|
@ -36,8 +36,9 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
|
||||||
Annex.eval state $ do
|
Annex.eval state $ do
|
||||||
checkEnvironment
|
checkEnvironment
|
||||||
forM_ fields $ uncurry Annex.setField
|
forM_ fields $ uncurry Annex.setField
|
||||||
(cmd, seek, globalconfig) <- parsewith cmdparser
|
(cmd, seek, globalconfig) <- parsewith False cmdparser
|
||||||
(\a -> inRepo $ a . Just)
|
(\a -> inRepo $ a . Just)
|
||||||
|
(liftIO . O.handleParseResult)
|
||||||
when (cmdnomessages cmd) $
|
when (cmdnomessages cmd) $
|
||||||
Annex.setOutput QuietOutput
|
Annex.setOutput QuietOutput
|
||||||
getParsed globalconfig
|
getParsed globalconfig
|
||||||
|
@ -47,20 +48,30 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
|
||||||
performCommandAction cmd seek $
|
performCommandAction cmd seek $
|
||||||
shutdown $ cmdnocommit cmd
|
shutdown $ cmdnocommit cmd
|
||||||
go (Left norepo) = do
|
go (Left norepo) = do
|
||||||
(_, a, _globalconfig) <- parsewith
|
let ingitrepo = \a -> a =<< Git.Config.global
|
||||||
|
-- Parse command line with full cmdparser first,
|
||||||
|
-- so that help can be displayed for bad parses
|
||||||
|
-- even when not run in a repo.
|
||||||
|
res <- parsewith False cmdparser ingitrepo return
|
||||||
|
case res of
|
||||||
|
Failure _ -> void (O.handleParseResult res)
|
||||||
|
_ -> do
|
||||||
|
-- Parse command line in norepo mode.
|
||||||
|
(_, a, _globalconfig) <- parsewith True
|
||||||
(fromMaybe (throw norepo) . cmdnorepo)
|
(fromMaybe (throw norepo) . cmdnorepo)
|
||||||
(\a -> a =<< Git.Config.global)
|
ingitrepo
|
||||||
|
O.handleParseResult
|
||||||
a
|
a
|
||||||
|
|
||||||
parsewith getparser ingitrepo =
|
parsewith secondrun getparser ingitrepo handleresult =
|
||||||
case parseCmd progname progdesc globaloptions allargs allcmds getparser of
|
case parseCmd progname progdesc globaloptions allargs allcmds getparser of
|
||||||
O.Failure _ -> do
|
O.Failure _ -> do
|
||||||
-- parse failed, so fall back to
|
-- parse failed, so fall back to
|
||||||
-- fuzzy matching, or to showing usage
|
-- fuzzy matching, or to showing usage
|
||||||
when fuzzy $
|
when (fuzzy && not secondrun) $
|
||||||
ingitrepo autocorrect
|
ingitrepo autocorrect
|
||||||
liftIO (O.handleParseResult (parseCmd progname progdesc globaloptions correctedargs allcmds getparser))
|
handleresult (parseCmd progname progdesc globaloptions correctedargs allcmds getparser)
|
||||||
res -> liftIO (O.handleParseResult res)
|
res -> handleresult res
|
||||||
where
|
where
|
||||||
autocorrect = Git.AutoCorrect.prepare (fromJust inputcmdname) cmdname cmds
|
autocorrect = Git.AutoCorrect.prepare (fromJust inputcmdname) cmdname cmds
|
||||||
(fuzzy, cmds, inputcmdname, args) = findCmd fuzzyok allargs allcmds
|
(fuzzy, cmds, inputcmdname, args) = findCmd fuzzyok allargs allcmds
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -5,6 +5,8 @@ git-annex (5.20150825) UNRELEASED; urgency=medium
|
||||||
* info: Support querying info of individual files in direct mode.
|
* info: Support querying info of individual files in direct mode.
|
||||||
* unused: Fix reversion in 5.20150727 that broke parsing of the
|
* unused: Fix reversion in 5.20150727 that broke parsing of the
|
||||||
--unused-refspec option. Thanks, Øyvind A. Holm.
|
--unused-refspec option. Thanks, Øyvind A. Holm.
|
||||||
|
* Make full option parsing be done when not in a git repo, so --help
|
||||||
|
can be displayed for commands that require a git repo, etc.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 01 Sep 2015 14:46:18 -0700
|
-- Joey Hess <id@joeyh.name> Tue, 01 Sep 2015 14:46:18 -0700
|
||||||
|
|
||||||
|
|
|
@ -22,3 +22,4 @@ remote types: git gcrypt S3 bup directory rsync web bittorrent webdav tahoe glac
|
||||||
|
|
||||||
YES -- lots of luck ;)
|
YES -- lots of luck ;)
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue