summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 15:08:02 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 15:08:02 -0400
commite7e61fb6cbe5455ded9bb550a64121223c099fc2 (patch)
tree003a99697256ea516ad40f9fbdb854996b58c0cd /CmdLine
parent8879c96d157f06bbd2372064251676b7927ce38e (diff)
convert all commands to work with optparse-applicative
Still no options though.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/Batch.hs2
-rw-r--r--CmdLine/GitAnnex.hs4
-rw-r--r--CmdLine/Usage.hs11
3 files changed, 10 insertions, 7 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs
index 836472eb0..24f942978 100644
--- a/CmdLine/Batch.hs
+++ b/CmdLine/Batch.hs
@@ -20,7 +20,7 @@ type Batchable t = BatchMode -> t -> CommandStart
-- In batch mode, one line at a time is read, parsed, and a reply output to
-- stdout. In non batch mode, the command's parameters are parsed and
-- a reply output for each.
-batchable :: ((t -> CommandStart) -> CommandSeek) -> Batchable t -> CommandSeek
+batchable :: ((t -> CommandStart) -> CmdParams -> CommandSeek) -> Batchable t -> CmdParams -> CommandSeek
batchable seeker starter params = ifM (getOptionFlag batchOption)
( batchloop
, seeker (starter NoBatch) params
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index 5619129f5..8967bc471 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -16,7 +16,6 @@ import Utility.Env
import Annex.Ssh
import qualified Command.Add
-{-
import qualified Command.Unannex
import qualified Command.Drop
import qualified Command.Move
@@ -117,12 +116,10 @@ import qualified Command.TestRemote
#ifdef WITH_EKG
import System.Remote.Monitoring
#endif
--}
cmds :: [Command]
cmds =
[ Command.Add.cmd
-{-
, Command.Get.cmd
, Command.Drop.cmd
, Command.Move.cmd
@@ -221,7 +218,6 @@ cmds =
, Command.FuzzTest.cmd
, Command.TestRemote.cmd
#endif
--}
]
header :: String
diff --git a/CmdLine/Usage.hs b/CmdLine/Usage.hs
index b386be9a6..58408762b 100644
--- a/CmdLine/Usage.hs
+++ b/CmdLine/Usage.hs
@@ -1,6 +1,6 @@
{- git-annex usage messages
-
- - Copyright 2010-2011 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2015 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -8,10 +8,10 @@
module CmdLine.Usage where
import Common.Annex
-
import Types.Command
import System.Console.GetOpt
+import qualified Options.Applicative as O
usageMessage :: String -> String
usageMessage s = "Usage: " ++ s
@@ -56,6 +56,13 @@ commandUsage cmd = unlines
, "[option ...]"
]
+{- Simple CommandParser generator, for when the CommandSeek wants all
+ - non-option parameters. -}
+withParams :: (CmdParams -> CommandSeek) -> String -> CommandParser
+withParams mkseek paramdesc = mkseek <$> O.many cmdparams
+ where
+ cmdparams = O.argument O.str (O.metavar paramdesc)
+
{- Descriptions of params used in usage messages. -}
paramPaths :: String
paramPaths = paramRepeating paramPath -- most often used