summaryrefslogtreecommitdiff
path: root/Command.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 /Command.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 'Command.hs')
-rw-r--r--Command.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/Command.hs b/Command.hs
index 35034a494..6522924c3 100644
--- a/Command.hs
+++ b/Command.hs
@@ -7,6 +7,7 @@
module Command (
command,
+ commandParser,
noRepo,
noCommit,
noMessages,
@@ -32,10 +33,17 @@ import CmdLine.Action as ReExported
import CmdLine.Option as ReExported
import CmdLine.GitAnnex.Options as ReExported
-{- Generates a normal command -}
-command :: String -> String -> CommandSeek -> CommandSection -> String -> Command
+import qualified Options.Applicative as O
+
+{- Generates a normal Command -}
+command :: String -> String -> CommandSection -> String -> CommandParser -> Command
command = Command [] Nothing commonChecks False False
+{- Simple CommandParser generator, for when the CommandSeek wants all
+ - non-option parameters. -}
+commandParser :: (CmdParams -> CommandSeek) -> CommandParser
+commandParser mkseek = mkseek <$> O.many (O.argument O.str O.idm)
+
{- Indicates that a command doesn't need to commit any changes to
- the git-annex branch. -}
noCommit :: Command -> Command