addon commands
Seems only fair, that, like git runs git-annex, git-annex runs git-annex-foo. Implementation relies on O.forwardOptions, so that any options are passed through to the addon program. Note that this includes options before the subcommand, eg: git-annex -cx=y foo Unfortunately, git-annex eats the --help/-h options. This is because it uses O.hsubparser, which injects that option into each subcommand. Seems like this should be possible to avoid somehow, to let commands display their own --help, instead of the dummy one git-annex displays. The two step searching mirrors how git works, it makes finding git-annex-foo fast when "git annex foo" is run, but will also support fuzzy matching, once findAllAddonCommands gets implemented. This commit was sponsored by Dr. Land Raider on Patreon.
This commit is contained in:
parent
e78d2c9642
commit
aec2cf0abe
9 changed files with 92 additions and 24 deletions
|
@ -1,14 +1,17 @@
|
|||
{- git-annex command data types
|
||||
-
|
||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
|
||||
module Types.Command where
|
||||
|
||||
import Data.Ord
|
||||
import Options.Applicative.Types (Parser)
|
||||
import Options.Applicative.Builder (InfoMod)
|
||||
|
||||
import Types
|
||||
import Types.DeferredParse
|
||||
|
@ -82,6 +85,8 @@ data Command = Command
|
|||
-- ^ description of command for usage
|
||||
, cmdparser :: CommandParser
|
||||
-- ^ command line parser
|
||||
, cmdinfomod :: forall a. InfoMod a
|
||||
-- ^ command-specific modifier for ParserInfo
|
||||
, cmdglobaloptions :: [GlobalOption]
|
||||
-- ^ additional global options
|
||||
, cmdnorepo :: Maybe (Parser (IO ()))
|
||||
|
@ -115,6 +120,7 @@ data CommandSection
|
|||
| SectionUtility
|
||||
| SectionPlumbing
|
||||
| SectionTesting
|
||||
| SectionAddOn
|
||||
deriving (Eq, Ord, Enum, Bounded)
|
||||
|
||||
descSection :: CommandSection -> String
|
||||
|
@ -126,3 +132,4 @@ descSection SectionMetaData = "Metadata commands"
|
|||
descSection SectionUtility = "Utility commands"
|
||||
descSection SectionPlumbing = "Plumbing commands"
|
||||
descSection SectionTesting = "Testing commands"
|
||||
descSection SectionAddOn = "Addon commands"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue