aboutsummaryrefslogtreecommitdiff
path: root/CmdLine/GitAnnexShell.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 12:33:27 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 13:36:25 -0400
commite73914b7950ce9d26a3882472c7ab27260ff87f9 (patch)
tree33d4a11106a005eadfe317505ea2786e83cf5bc8 /CmdLine/GitAnnexShell.hs
parent8ce422d8ab390e105d70f049c30d81c14d3b64b4 (diff)
started converting to use optparse-applicative
This is a work in progress. It compiles and is able to do basic command dispatch, including git autocorrection, while using optparse-applicative for the core commandline parsing. * Many commands are temporarily disabled before conversion. * Options are not wired in yet. * cmdnorepo actions don't work yet. Also, removed the [Command] list, which was only used in one place.
Diffstat (limited to 'CmdLine/GitAnnexShell.hs')
-rw-r--r--CmdLine/GitAnnexShell.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs
index adf6da04e..fca37790b 100644
--- a/CmdLine/GitAnnexShell.hs
+++ b/CmdLine/GitAnnexShell.hs
@@ -16,7 +16,6 @@ import qualified Git.Config
import CmdLine
import Command
import Annex.UUID
-import Annex (setField)
import CmdLine.GitAnnexShell.Fields
import Utility.UserInfo
import Remote.GCrypt (getGCryptUUID)
@@ -34,7 +33,7 @@ import qualified Command.NotifyChanges
import qualified Command.GCryptSetup
cmds_readonly :: [Command]
-cmds_readonly = concat
+cmds_readonly =
[ gitAnnexShellCheck Command.ConfigList.cmd
, gitAnnexShellCheck Command.InAnnex.cmd
, gitAnnexShellCheck Command.SendKey.cmd
@@ -43,7 +42,7 @@ cmds_readonly = concat
]
cmds_notreadonly :: [Command]
-cmds_notreadonly = concat
+cmds_notreadonly =
[ gitAnnexShellCheck Command.RecvKey.cmd
, gitAnnexShellCheck Command.DropKey.cmd
, gitAnnexShellCheck Command.Commit.cmd
@@ -100,12 +99,10 @@ builtin cmd dir params = do
checkNotReadOnly cmd
checkDirectory $ Just dir
let (params', fieldparams, opts) = partitionParams params
- fields = filter checkField $ parseFields fieldparams
- cmds' = map (newcmd $ unwords opts) cmds
- dispatch False (cmd : params') cmds' options fields header mkrepo
+ rsyncopts = ("RsyncOptions", unwords opts)
+ fields = rsyncopts : filter checkField (parseFields fieldparams)
+ dispatch False (cmd : params') cmds options fields header mkrepo
where
- addrsyncopts opts seek k = setField "RsyncOptions" opts >> seek k
- newcmd opts c = c { cmdseek = addrsyncopts opts (cmdseek c) }
mkrepo = do
r <- Git.Construct.repoAbsPath dir >>= Git.Construct.fromAbsPath
Git.Config.read r
@@ -200,8 +197,8 @@ checkEnv var = do
{- Modifies a Command to check that it is run in either a git-annex
- repository, or a repository with a gcrypt-id set. -}
-gitAnnexShellCheck :: [Command] -> [Command]
-gitAnnexShellCheck = map $ addCheck okforshell . dontCheck repoExists
+gitAnnexShellCheck :: Command -> Command
+gitAnnexShellCheck = addCheck okforshell . dontCheck repoExists
where
okforshell = unlessM (isInitialized <||> isJust . gcryptId <$> Annex.getGitConfig) $
error "Not a git-annex or gcrypt repository."