{- | All the concrete options.

Notes:

  * The term \"option\" refers to a flag or combination of flags that
    together form a part of a command's configuration. Ideally, options
    should be orthogonal to each other, so we can freely combine them.

  * A primitive (indivisible) option has an associate value type.

  * An option named \"xyzActions\" represents a set of flags that act as
    mutually exclusive sub-commands. They typically have a dedicated value
    type named \"XyzAction\".

  * This module is probably best imported qualified. This is in contrast to
    the current practice of using subtly differing names to avoid name
    clashes for closely related items. For instance, the data constructors
    for an option's value type and the corresponding data constructors in
    'F.DarcsFlag' may coincide. This is also why we import "Darcs.UI.Flags"
    qualified here.

  * When the new options system is finally in place, no code other than the
    one for constructing options should directly refer to 'F.DarcsFlag'
    constructors.

-}
module Darcs.UI.Options.All
    ( DarcsOption

    -- conversion to 'Bool'
    , YesNo (..)

    -- root
    , RootAction (..)
    , rootActions

    -- all commands
    , StdCmdAction (..)
    , stdCmdActions
    , debug
    , Verbosity (..) -- re-export
    , verbosity
    , timings
    , debugging
    , HooksConfig (..) -- re-export
    , HookConfig (..) -- re-export
    , preHook
    , postHook
    , hooks
    , UseCache (..) -- re-export
    , useCache

    -- interactivity
    , XmlOutput (..)
    , xmlOutput
    , DryRun (..) -- re-export
    , dryRun
    , dryRunXml
    , interactive
    , pipe
    , WantGuiPause (..) -- re-export
    , pauseForGui
    , askDeps

    -- patch selection
    , module Darcs.UI.Options.Matching -- re-export
    , SelectDeps (..)
    , selectDeps
    , changesReverse
    , maxCount

    -- local or remote repo(s)
    , repoDir
    , RemoteRepos (..) -- re-export
    , remoteRepos
    , possiblyRemoteRepo
    , newRepo
    , NotInRemote (..)
    , notInRemote
    , notInRemoteFlagName
    , RepoCombinator (..)
    , repoCombinator
    , allowUnrelatedRepos
    , justThisRepo
    , WithWorkingDir (..) -- re-export
    , withWorkingDir
    , SetDefault (..) -- re-export
    , setDefault
    , InheritDefault (..) -- re-export
    , inheritDefault

    -- patch meta-data
    , patchname
    , author
    , AskLongComment (..)
    , askLongComment
    , keepDate
    , Logfile (..)
    , logfile

    -- looking for changes
    , LookFor (..)
    , LookForAdds (..) -- re-export
    , LookForMoves (..) -- re-export
    , LookForReplaces (..) -- re-export
    , lookfor
    , lookforadds
    , lookforreplaces
    , lookformoves

    -- files to consider
    , UseIndex (..) -- re-export
    , ScanKnown (..) -- re-export
    , IncludeBoring (..)
    , includeBoring
    , allowProblematicFilenames
    , allowCaseDifferingFilenames
    , allowWindowsReservedFilenames
    , onlyToFiles
    , useIndex
    , recursive

    -- differences
    , DiffAlgorithm (..) -- re-export
    , diffAlgorithm
    , WithContext (..)
    , withContext
    , ExternalDiff (..)
    , extDiff

    -- tests
    , TestChanges (..)
    , testChanges
    , RunTest (..) -- re-export
    , runTest
    , LeaveTestDir (..) -- re-export
    , leaveTestDir

    -- mail related
    , HeaderFields (..)
    , headerFields
    , sendToContext
    , sendmail
    , sendmailCmd
    , charset
    , editDescription

    -- patch bundles
    , applyAs
    , Sign (..)
    , sign
    , Verify (..)
    , verify

    -- merging patches
    , AllowConflicts (..) -- re-export
    , conflictsNo
    , conflictsYes
    , ExternalMerge (..) -- re-export
    , externalMerge
    , reorder

    -- optimizations
    , Compression (..) -- re-export
    , compress
    , usePacks
    , WithPatchIndex (..) -- re-export
    , patchIndexNo
    , patchIndexYes
    , Reorder (..) -- re-export
    , minimize
    , storeInMemory

    -- miscellaneous
    , Output (..)
    , output
    , WithSummary (..)
    , withSummary
    , maybeSummary
    , RemoteDarcs (..) -- re-export
    , NetworkOptions (..)
    , network
    , UMask (..) -- re-export
    , umask
    , SetScriptsExecutable (..) -- re-export
    , setScriptsExecutable

    -- command specific

    -- amend
    , amendUnrecord
    , selectAuthor

    -- annotate
    , machineReadable

    -- clone
    , CloneKind (..)
    , cloneKind

    -- dist
    , distname
    , distzip

    -- convert import/export, init
    , marks
    , readMarks
    , writeMarks
    , PatchFormat (..)
    , patchFormat
    , hashed

    -- log
    , ChangesFormat (..)
    , changesFormat

    -- replace
    , tokens
    , forceReplace

    -- test
    , TestStrategy (..)
    , testStrategy

    -- show files/index
    , files
    , directories
    , pending
    , nullFlag

    -- show repo
    , EnumPatches (..)
    , enumPatches

    -- gzcrcs
    , GzcrcsAction (..)
    , gzcrcsActions

    -- optimize
    , siblings
    ) where

import Darcs.Prelude

import Darcs.Repository.Flags
    ( Compression (..)
    , RemoteDarcs (..)
    , Reorder (..)
    , Verbosity (..)
    , UseCache (..)
    , UMask (..)
    , DryRun (..)
    , LookForAdds (..)
    , LookForMoves (..)
    , LookForReplaces (..)
    , DiffAlgorithm (..)
    , RunTest (..)
    , SetScriptsExecutable (..)
    , LeaveTestDir (..)
    , RemoteRepos (..)
    , SetDefault (..)
    , InheritDefault (..)
    , UseIndex (..)
    , ScanKnown (..)
    , CloneKind (..)
    , ExternalMerge (..)
    , AllowConflicts (..)
    , WantGuiPause (..)
    , WithPatchIndex (..)
    , WithWorkingDir (..)
    , PatchFormat (..)
    , IncludeBoring (..)
    , HooksConfig (..)
    , HookConfig (..)
    )

import qualified Darcs.UI.Options.Flags as F ( DarcsFlag(..) )
import Darcs.UI.Options.Core
import Darcs.UI.Options.Iso
import Darcs.UI.Options.Util
import Darcs.UI.Options.Matching

-- * Type instantiations

-- | 'DarcsOption' instantiates the first two type parameters of 'OptSpec' to
-- what we need in darcs. The first parameter is instantiated to
-- The flag type is instantiate to 'Flag'.
type DarcsOption = OptSpec DarcsOptDescr Flag

type RawDarcsOption = forall v. v -> RawOptSpec Flag v

-- * Conversion to 'Bool'

class YesNo a where
  yes :: a -> Bool
  no :: a -> Bool
  no = Bool -> Bool
not (Bool -> Bool) -> (a -> Bool) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Bool
forall a. YesNo a => a -> Bool
yes

instance YesNo Compression where
  yes :: Compression -> Bool
yes Compression
NoCompression = Bool
False
  yes Compression
GzipCompression = Bool
True

instance YesNo WithPatchIndex where
  yes :: WithPatchIndex -> Bool
yes WithPatchIndex
NoPatchIndex = Bool
False
  yes WithPatchIndex
YesPatchIndex = Bool
True

instance YesNo Reorder where
  yes :: Reorder -> Bool
yes Reorder
NoReorder = Bool
False
  yes Reorder
Reorder = Bool
True

instance YesNo UseCache where
  yes :: UseCache -> Bool
yes UseCache
NoUseCache = Bool
False
  yes UseCache
YesUseCache = Bool
True

instance YesNo DryRun where
  yes :: DryRun -> Bool
yes DryRun
NoDryRun = Bool
False
  yes DryRun
YesDryRun = Bool
True

instance YesNo LookForAdds where
  yes :: LookForAdds -> Bool
yes LookForAdds
NoLookForAdds = Bool
False
  yes LookForAdds
YesLookForAdds = Bool
True

instance YesNo LookForReplaces where
  yes :: LookForReplaces -> Bool
yes LookForReplaces
NoLookForReplaces = Bool
False
  yes LookForReplaces
YesLookForReplaces = Bool
True

instance YesNo LookForMoves where
  yes :: LookForMoves -> Bool
yes LookForMoves
NoLookForMoves = Bool
False
  yes LookForMoves
YesLookForMoves = Bool
True

instance YesNo IncludeBoring where
  yes :: IncludeBoring -> Bool
yes IncludeBoring
NoIncludeBoring = Bool
False
  yes IncludeBoring
YesIncludeBoring = Bool
True

instance YesNo RunTest where
  yes :: RunTest -> Bool
yes RunTest
NoRunTest = Bool
False
  yes RunTest
YesRunTest = Bool
True

instance YesNo SetScriptsExecutable where
  yes :: SetScriptsExecutable -> Bool
yes SetScriptsExecutable
NoSetScriptsExecutable = Bool
False
  yes SetScriptsExecutable
YesSetScriptsExecutable = Bool
True

instance YesNo LeaveTestDir where
  yes :: LeaveTestDir -> Bool
yes LeaveTestDir
NoLeaveTestDir = Bool
False
  yes LeaveTestDir
YesLeaveTestDir = Bool
True

instance YesNo UseIndex where
  yes :: UseIndex -> Bool
yes UseIndex
IgnoreIndex = Bool
False
  yes UseIndex
UseIndex = Bool
True

instance YesNo WantGuiPause where
  yes :: WantGuiPause -> Bool
yes WantGuiPause
NoWantGuiPause = Bool
False
  yes WantGuiPause
YesWantGuiPause = Bool
True

instance YesNo WithWorkingDir where
  yes :: WithWorkingDir -> Bool
yes WithWorkingDir
NoWorkingDir = Bool
False
  yes WithWorkingDir
WithWorkingDir = Bool
True

data EnumPatches = NoEnumPatches | YesEnumPatches deriving (EnumPatches -> EnumPatches -> Bool
(EnumPatches -> EnumPatches -> Bool)
-> (EnumPatches -> EnumPatches -> Bool) -> Eq EnumPatches
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumPatches -> EnumPatches -> Bool
$c/= :: EnumPatches -> EnumPatches -> Bool
== :: EnumPatches -> EnumPatches -> Bool
$c== :: EnumPatches -> EnumPatches -> Bool
Eq, Int -> EnumPatches -> ShowS
[EnumPatches] -> ShowS
EnumPatches -> String
(Int -> EnumPatches -> ShowS)
-> (EnumPatches -> String)
-> ([EnumPatches] -> ShowS)
-> Show EnumPatches
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnumPatches] -> ShowS
$cshowList :: [EnumPatches] -> ShowS
show :: EnumPatches -> String
$cshow :: EnumPatches -> String
showsPrec :: Int -> EnumPatches -> ShowS
$cshowsPrec :: Int -> EnumPatches -> ShowS
Show)

instance YesNo EnumPatches where
  yes :: EnumPatches -> Bool
yes EnumPatches
NoEnumPatches = Bool
False
  yes EnumPatches
YesEnumPatches = Bool
True

instance YesNo InheritDefault where
  yes :: InheritDefault -> Bool
yes InheritDefault
NoInheritDefault = Bool
False
  yes InheritDefault
YesInheritDefault = Bool
True

-- * Root command

-- | Options for darcs iself that act like sub-commands.
data RootAction = RootHelp | Version | ExactVersion | ListCommands deriving (RootAction -> RootAction -> Bool
(RootAction -> RootAction -> Bool)
-> (RootAction -> RootAction -> Bool) -> Eq RootAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RootAction -> RootAction -> Bool
$c/= :: RootAction -> RootAction -> Bool
== :: RootAction -> RootAction -> Bool
$c== :: RootAction -> RootAction -> Bool
Eq, Int -> RootAction -> ShowS
[RootAction] -> ShowS
RootAction -> String
(Int -> RootAction -> ShowS)
-> (RootAction -> String)
-> ([RootAction] -> ShowS)
-> Show RootAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RootAction] -> ShowS
$cshowList :: [RootAction] -> ShowS
show :: RootAction -> String
$cshow :: RootAction -> String
showsPrec :: Int -> RootAction -> ShowS
$cshowsPrec :: Int -> RootAction -> ShowS
Show)

rootActions :: PrimDarcsOption (Maybe RootAction)
rootActions :: PrimOptSpec DarcsOptDescr Flag a (Maybe RootAction)
rootActions = Maybe RootAction
-> [RawOptSpec Flag (Maybe RootAction)]
-> PrimDarcsOption (Maybe RootAction)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe RootAction
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe RootAction
-> String
-> RawOptSpec Flag (Maybe RootAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'h'] [String
"help"] Flag
F.Help (RootAction -> Maybe RootAction
forall a. a -> Maybe a
Just RootAction
RootHelp)
    String
"show a brief description of all darcs commands and top-level options"
  , String
-> [String]
-> Flag
-> Maybe RootAction
-> String
-> RawOptSpec Flag (Maybe RootAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'v',Char
'V'] [String
"version"] Flag
F.Version  (RootAction -> Maybe RootAction
forall a. a -> Maybe a
Just RootAction
Version) String
"show the darcs version"
  , String
-> [String]
-> Flag
-> Maybe RootAction
-> String
-> RawOptSpec Flag (Maybe RootAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"exact-version"] Flag
F.ExactVersion (RootAction -> Maybe RootAction
forall a. a -> Maybe a
Just RootAction
ExactVersion)
    String
"show the exact darcs version"
    -- the switch --commands is here for compatibility only
  , String
-> [String]
-> Flag
-> Maybe RootAction
-> String
-> RawOptSpec Flag (Maybe RootAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"commands"] Flag
F.ListCommands (RootAction -> Maybe RootAction
forall a. a -> Maybe a
Just RootAction
ListCommands)
    String
"show plain list of available options and commands, for auto-completion"
  ]

-- * Common to all commands

-- ** Standard command actions

data StdCmdAction = Help | ListOptions | Disable deriving (StdCmdAction -> StdCmdAction -> Bool
(StdCmdAction -> StdCmdAction -> Bool)
-> (StdCmdAction -> StdCmdAction -> Bool) -> Eq StdCmdAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StdCmdAction -> StdCmdAction -> Bool
$c/= :: StdCmdAction -> StdCmdAction -> Bool
== :: StdCmdAction -> StdCmdAction -> Bool
$c== :: StdCmdAction -> StdCmdAction -> Bool
Eq, Int -> StdCmdAction -> ShowS
[StdCmdAction] -> ShowS
StdCmdAction -> String
(Int -> StdCmdAction -> ShowS)
-> (StdCmdAction -> String)
-> ([StdCmdAction] -> ShowS)
-> Show StdCmdAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StdCmdAction] -> ShowS
$cshowList :: [StdCmdAction] -> ShowS
show :: StdCmdAction -> String
$cshow :: StdCmdAction -> String
showsPrec :: Int -> StdCmdAction -> ShowS
$cshowsPrec :: Int -> StdCmdAction -> ShowS
Show)

stdCmdActions :: PrimDarcsOption (Maybe StdCmdAction)
stdCmdActions :: PrimOptSpec DarcsOptDescr Flag a (Maybe StdCmdAction)
stdCmdActions = Maybe StdCmdAction
-> [RawOptSpec Flag (Maybe StdCmdAction)]
-> PrimDarcsOption (Maybe StdCmdAction)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe StdCmdAction
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe StdCmdAction
-> String
-> RawOptSpec Flag (Maybe StdCmdAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"help"] Flag
F.Help (StdCmdAction -> Maybe StdCmdAction
forall a. a -> Maybe a
Just StdCmdAction
Help)
    String
"show a description of the command and its options"
  , String
-> [String]
-> Flag
-> Maybe StdCmdAction
-> String
-> RawOptSpec Flag (Maybe StdCmdAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"list-options"] Flag
F.ListOptions (StdCmdAction -> Maybe StdCmdAction
forall a. a -> Maybe a
Just StdCmdAction
ListOptions)
    String
"show plain list of available options and commands, for auto-completion"
  , String
-> [String]
-> Flag
-> Maybe StdCmdAction
-> String
-> RawOptSpec Flag (Maybe StdCmdAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"disable"] Flag
F.Disable (StdCmdAction -> Maybe StdCmdAction
forall a. a -> Maybe a
Just StdCmdAction
Disable) String
"disable this command" ]

-- ** Verbosity related

debug :: PrimDarcsOption Bool
debug :: PrimOptSpec DarcsOptDescr Flag a Bool
debug = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"debug"] Flag
F.Debug String
"enable general debug output"

debugHttp :: PrimDarcsOption Bool
debugHttp :: PrimOptSpec DarcsOptDescr Flag a Bool
debugHttp = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"debug-http"] Flag
F.DebugHTTP String
"debug output from libcurl"

verbosity :: PrimDarcsOption Verbosity
verbosity :: PrimOptSpec DarcsOptDescr Flag a Verbosity
verbosity = Verbosity
-> [RawOptSpec Flag Verbosity] -> PrimDarcsOption Verbosity
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Verbosity
NormalVerbosity
  [ String
-> [String]
-> Flag
-> Verbosity
-> String
-> RawOptSpec Flag Verbosity
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'q'] [String
"quiet"] Flag
F.Quiet Verbosity
Quiet String
"suppress informational output"
  , String
-> [String]
-> Flag
-> Verbosity
-> String
-> RawOptSpec Flag Verbosity
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"standard-verbosity"] Flag
F.NormalVerbosity Verbosity
NormalVerbosity
      String
"neither verbose nor quiet output"
  , String
-> [String]
-> Flag
-> Verbosity
-> String
-> RawOptSpec Flag Verbosity
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'v'] [String
"verbose"] Flag
F.Verbose Verbosity
Verbose String
"enable verbose output" ]

timings :: PrimDarcsOption Bool
timings :: PrimOptSpec DarcsOptDescr Flag a Bool
timings = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"timings"] Flag
F.Timings String
"provide debugging timings information"

debugging :: DarcsOption a (Bool -> Bool -> Bool -> a)
debugging :: DarcsOption a (Bool -> Bool -> Bool -> a)
debugging = PrimOptSpec DarcsOptDescr Flag (Bool -> Bool -> a) Bool
PrimDarcsOption Bool
debug PrimOptSpec DarcsOptDescr Flag (Bool -> Bool -> a) Bool
-> OptSpec DarcsOptDescr Flag (Bool -> a) (Bool -> Bool -> a)
-> OptSpec
     DarcsOptDescr Flag (Bool -> a) (Bool -> Bool -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag (Bool -> a) (Bool -> Bool -> a)
PrimDarcsOption Bool
debugHttp OptSpec DarcsOptDescr Flag (Bool -> a) (Bool -> Bool -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> DarcsOption a (Bool -> Bool -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Bool -> a)
PrimDarcsOption Bool
timings

-- ** Hooks

hooks :: DarcsOption a (HooksConfig -> a)
hooks :: DarcsOption a (HooksConfig -> a)
hooks = Iso (HookConfig -> HookConfig -> a) (HooksConfig -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
-> DarcsOption a (HooksConfig -> a)
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((HookConfig -> HookConfig -> a) -> HooksConfig -> a)
-> ((HooksConfig -> a) -> HookConfig -> HookConfig -> a)
-> Iso (HookConfig -> HookConfig -> a) (HooksConfig -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (HookConfig -> HookConfig -> a) -> HooksConfig -> a
forall t. (HookConfig -> HookConfig -> t) -> HooksConfig -> t
fw (HooksConfig -> a) -> HookConfig -> HookConfig -> a
forall t. (HooksConfig -> t) -> HookConfig -> HookConfig -> t
bw) (OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
 -> DarcsOption a (HooksConfig -> a))
-> OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
-> DarcsOption a (HooksConfig -> a)
forall a b. (a -> b) -> a -> b
$ DarcsOption (HookConfig -> a) (HookConfig -> HookConfig -> a)
forall a. DarcsOption a (HookConfig -> a)
preHook DarcsOption (HookConfig -> a) (HookConfig -> HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (HookConfig -> a)
forall a. DarcsOption a (HookConfig -> a)
postHook where
  fw :: (HookConfig -> HookConfig -> t) -> HooksConfig -> t
fw HookConfig -> HookConfig -> t
k (HooksConfig HookConfig
pr HookConfig
po) = HookConfig -> HookConfig -> t
k HookConfig
pr HookConfig
po
  bw :: (HooksConfig -> t) -> HookConfig -> HookConfig -> t
bw HooksConfig -> t
k HookConfig
pr HookConfig
po = HooksConfig -> t
k (HookConfig -> HookConfig -> HooksConfig
HooksConfig HookConfig
pr HookConfig
po)

hookIso :: Iso (Maybe String -> Bool -> a) (HookConfig -> a)
hookIso :: Iso (Maybe String -> Bool -> a) (HookConfig -> a)
hookIso = (((Maybe String -> Bool -> a) -> HookConfig -> a)
-> ((HookConfig -> a) -> Maybe String -> Bool -> a)
-> Iso (Maybe String -> Bool -> a) (HookConfig -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Maybe String -> Bool -> a) -> HookConfig -> a
forall t. (Maybe String -> Bool -> t) -> HookConfig -> t
fw (HookConfig -> a) -> Maybe String -> Bool -> a
forall t. (HookConfig -> t) -> Maybe String -> Bool -> t
bw) where
    fw :: (Maybe String -> Bool -> t) -> HookConfig -> t
fw Maybe String -> Bool -> t
k (HookConfig Maybe String
c Bool
p) = Maybe String -> Bool -> t
k Maybe String
c Bool
p
    bw :: (HookConfig -> t) -> Maybe String -> Bool -> t
bw HookConfig -> t
k Maybe String
c Bool
p = HookConfig -> t
k (Maybe String -> Bool -> HookConfig
HookConfig Maybe String
c Bool
p)

preHook :: DarcsOption a (HookConfig -> a)
preHook :: DarcsOption a (HookConfig -> a)
preHook = Iso (Maybe String -> Bool -> a) (HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> DarcsOption a (HookConfig -> a)
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap Iso (Maybe String -> Bool -> a) (HookConfig -> a)
forall a. Iso (Maybe String -> Bool -> a) (HookConfig -> a)
hookIso (OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
 -> DarcsOption a (HookConfig -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> DarcsOption a (HookConfig -> a)
forall a b. (a -> b) -> a -> b
$ PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe String)
PrimDarcsOption (Maybe String)
prehookCmd PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe String)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ String -> Flag -> Flag -> PrimDarcsOption Bool
hookPrompt String
"prehook" Flag
F.AskPrehook Flag
F.RunPrehook

postHook :: DarcsOption a (HookConfig -> a)
postHook :: DarcsOption a (HookConfig -> a)
postHook = Iso (Maybe String -> Bool -> a) (HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> DarcsOption a (HookConfig -> a)
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap Iso (Maybe String -> Bool -> a) (HookConfig -> a)
forall a. Iso (Maybe String -> Bool -> a) (HookConfig -> a)
hookIso (OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
 -> DarcsOption a (HookConfig -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> DarcsOption a (HookConfig -> a)
forall a b. (a -> b) -> a -> b
$ PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe String)
PrimDarcsOption (Maybe String)
posthookCmd PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe String)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ String -> Flag -> Flag -> PrimDarcsOption Bool
hookPrompt String
"posthook" Flag
F.AskPosthook Flag
F.RunPosthook

prehookCmd :: PrimDarcsOption (Maybe String)
prehookCmd :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
prehookCmd = Maybe String
-> [RawOptSpec Flag (Maybe String)]
-> PrimDarcsOption (Maybe String)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe String
forall a. Maybe a
Nothing
    [ String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Maybe String)
-> (Maybe String -> [String])
-> String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"prehook"] String -> Flag
F.PrehookCmd Flag -> [String]
unF String -> Maybe String
forall a. a -> Maybe a
Just Maybe String -> [String]
forall a. Maybe a -> [a]
unV
      String
"COMMAND" String
"specify command to run before this darcs command"
    , String
-> [String]
-> Flag
-> Maybe String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-prehook"] Flag
F.NoPrehook Maybe String
forall a. Maybe a
Nothing
      String
"don't run prehook command" ]
  where unF :: Flag -> [String]
unF Flag
f = [ String
s | F.PrehookCmd String
s <- [Flag
f] ]
        unV :: Maybe a -> [a]
unV Maybe a
v = [ a
s | Just a
s <- [Maybe a
v] ]

posthookCmd :: PrimDarcsOption (Maybe String)
posthookCmd :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
posthookCmd = Maybe String
-> [RawOptSpec Flag (Maybe String)]
-> PrimDarcsOption (Maybe String)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe String
forall a. Maybe a
Nothing
    [ String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Maybe String)
-> (Maybe String -> [String])
-> String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"posthook"] String -> Flag
F.PosthookCmd Flag -> [String]
unF String -> Maybe String
forall a. a -> Maybe a
Just Maybe String -> [String]
forall a. Maybe a -> [a]
unV String
"COMMAND"
      String
"specify command to run after this darcs command"
    , String
-> [String]
-> Flag
-> Maybe String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-posthook"] Flag
F.NoPosthook Maybe String
forall a. Maybe a
Nothing
      String
"don't run posthook command" ]
  where unF :: Flag -> [String]
unF Flag
f = [ String
s | F.PosthookCmd String
s <- [Flag
f] ]
        unV :: Maybe a -> [a]
unV Maybe a
v = [ a
s | Just a
s <- [Maybe a
v] ]

hookPrompt :: String -> Flag -> Flag -> PrimDarcsOption Bool
hookPrompt :: String -> Flag -> Flag -> PrimDarcsOption Bool
hookPrompt String
name Flag
fask Flag
frun = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"prompt-"String -> ShowS
forall a. [a] -> [a] -> [a]
++String
name] Flag
fask Bool
True
    (String
"prompt before running "String -> ShowS
forall a. [a] -> [a] -> [a]
++String
name)
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"run-"String -> ShowS
forall a. [a] -> [a] -> [a]
++String
name] Flag
frun Bool
False
    (String
"run "String -> ShowS
forall a. [a] -> [a] -> [a]
++String
nameString -> ShowS
forall a. [a] -> [a] -> [a]
++String
" command without prompting") ]

-- ** Misc

useCache :: PrimDarcsOption UseCache
useCache :: PrimOptSpec DarcsOptDescr Flag a UseCache
useCache = (Iso (Bool -> a) (UseCache -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a UseCache
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso (Bool -> a) (UseCache -> a)
 -> OptSpec DarcsOptDescr Flag a (Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a UseCache)
-> (Iso Bool UseCache -> Iso (Bool -> a) (UseCache -> a))
-> Iso Bool UseCache
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a UseCache
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso Bool UseCache -> Iso (Bool -> a) (UseCache -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) ((Bool -> UseCache) -> (UseCache -> Bool) -> Iso Bool UseCache
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso Bool -> UseCache
fw UseCache -> Bool
bw) (OptSpec DarcsOptDescr Flag a (Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a UseCache)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a UseCache
forall a b. (a -> b) -> a -> b
$ String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"no-cache"] Flag
F.NoCache String
"don't use patch caches"
  where
    fw :: Bool -> UseCache
fw Bool
True = UseCache
NoUseCache
    fw Bool
False = UseCache
YesUseCache
    bw :: UseCache -> Bool
bw UseCache
NoUseCache = Bool
True
    bw UseCache
YesUseCache = Bool
False

-- * Interactivity related

{- TODO: These options interact (no pun intended) in complex ways that are
very hard to figure out for users as well as maintainers. I think the only
solution here is a more radical (and probably incompatible) re-design
involving all interactivity related options. -}

data XmlOutput = NoXml | YesXml deriving (XmlOutput -> XmlOutput -> Bool
(XmlOutput -> XmlOutput -> Bool)
-> (XmlOutput -> XmlOutput -> Bool) -> Eq XmlOutput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XmlOutput -> XmlOutput -> Bool
$c/= :: XmlOutput -> XmlOutput -> Bool
== :: XmlOutput -> XmlOutput -> Bool
$c== :: XmlOutput -> XmlOutput -> Bool
Eq, Int -> XmlOutput -> ShowS
[XmlOutput] -> ShowS
XmlOutput -> String
(Int -> XmlOutput -> ShowS)
-> (XmlOutput -> String)
-> ([XmlOutput] -> ShowS)
-> Show XmlOutput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XmlOutput] -> ShowS
$cshowList :: [XmlOutput] -> ShowS
show :: XmlOutput -> String
$cshow :: XmlOutput -> String
showsPrec :: Int -> XmlOutput -> ShowS
$cshowsPrec :: Int -> XmlOutput -> ShowS
Show)

instance YesNo XmlOutput where
  yes :: XmlOutput -> Bool
yes XmlOutput
NoXml = Bool
False
  yes XmlOutput
YesXml = Bool
True

xmlOutput :: PrimDarcsOption XmlOutput
xmlOutput :: PrimOptSpec DarcsOptDescr Flag a XmlOutput
xmlOutput = XmlOutput
-> [RawOptSpec Flag XmlOutput] -> PrimDarcsOption XmlOutput
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault XmlOutput
NoXml [XmlOutput -> RawOptSpec Flag XmlOutput
RawDarcsOption
__xmloutput XmlOutput
YesXml]

__xmloutput :: RawDarcsOption
__xmloutput :: v -> RawOptSpec Flag v
__xmloutput v
val = String -> [String] -> Flag -> v -> String -> RawOptSpec Flag v
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"xml-output"] Flag
F.XMLOutput v
val String
"generate XML formatted output"

-- | TODO someone wrote here long ago that any time --dry-run is a possibility
-- automated users should be able to examine the results more
-- easily with --xml. See also issue2397.
-- dryRun w/o xml is currently used in add, pull, and repair.

dryRun :: PrimDarcsOption DryRun
dryRun :: PrimOptSpec DarcsOptDescr Flag a DryRun
dryRun = DryRun -> [RawOptSpec Flag DryRun] -> PrimDarcsOption DryRun
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault DryRun
NoDryRun
  [ String
-> [String] -> Flag -> DryRun -> String -> RawOptSpec Flag DryRun
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dry-run"] Flag
F.DryRun DryRun
YesDryRun String
"don't actually take the action" ]

dryRunXml :: DarcsOption a (DryRun -> XmlOutput -> a)
dryRunXml :: DarcsOption a (DryRun -> XmlOutput -> a)
dryRunXml = PrimOptSpec DarcsOptDescr Flag (XmlOutput -> a) DryRun
PrimDarcsOption DryRun
dryRun PrimOptSpec DarcsOptDescr Flag (XmlOutput -> a) DryRun
-> OptSpec DarcsOptDescr Flag a (XmlOutput -> a)
-> DarcsOption a (DryRun -> XmlOutput -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (XmlOutput -> a)
PrimDarcsOption XmlOutput
xmlOutput

pipe :: PrimDarcsOption Bool
pipe :: PrimOptSpec DarcsOptDescr Flag a Bool
pipe = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"pipe"] Flag
F.Pipe String
"ask user interactively for the patch metadata"

interactive :: PrimDarcsOption (Maybe Bool)
interactive :: PrimOptSpec DarcsOptDescr Flag a (Maybe Bool)
interactive = Maybe Bool
-> [RawOptSpec Flag (Maybe Bool)] -> PrimDarcsOption (Maybe Bool)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe Bool
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe Bool
-> String
-> RawOptSpec Flag (Maybe Bool)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'a'] [String
"all",String
"no-interactive"] Flag
F.All (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False) String
"answer yes to all patches"
  , String
-> [String]
-> Flag
-> Maybe Bool
-> String
-> RawOptSpec Flag (Maybe Bool)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'i'] [String
"interactive"] Flag
F.Interactive (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True) String
"prompt user interactively" ]

pauseForGui :: PrimDarcsOption WantGuiPause
pauseForGui :: PrimOptSpec DarcsOptDescr Flag a WantGuiPause
pauseForGui = WantGuiPause
-> [RawOptSpec Flag WantGuiPause] -> PrimDarcsOption WantGuiPause
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault WantGuiPause
YesWantGuiPause
  [ String
-> [String]
-> Flag
-> WantGuiPause
-> String
-> RawOptSpec Flag WantGuiPause
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"pause-for-gui"] Flag
F.PauseForGui WantGuiPause
YesWantGuiPause
    String
"pause for an external diff or merge command to finish"
  , String
-> [String]
-> Flag
-> WantGuiPause
-> String
-> RawOptSpec Flag WantGuiPause
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-pause-for-gui"] Flag
F.NoPauseForGui WantGuiPause
NoWantGuiPause
    String
"return immediately after external diff or merge command finishes" ]

askDeps :: PrimDarcsOption Bool
askDeps :: PrimOptSpec DarcsOptDescr Flag a Bool
askDeps = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"ask-deps"] Flag
F.AskDeps Bool
True String
"manually select dependencies"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-ask-deps"] Flag
F.NoAskDeps Bool
False String
"automatically select dependencies" ]

-- * Patch selection related

data SelectDeps = NoDeps | AutoDeps | PromptDeps deriving (SelectDeps -> SelectDeps -> Bool
(SelectDeps -> SelectDeps -> Bool)
-> (SelectDeps -> SelectDeps -> Bool) -> Eq SelectDeps
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectDeps -> SelectDeps -> Bool
$c/= :: SelectDeps -> SelectDeps -> Bool
== :: SelectDeps -> SelectDeps -> Bool
$c== :: SelectDeps -> SelectDeps -> Bool
Eq, Int -> SelectDeps -> ShowS
[SelectDeps] -> ShowS
SelectDeps -> String
(Int -> SelectDeps -> ShowS)
-> (SelectDeps -> String)
-> ([SelectDeps] -> ShowS)
-> Show SelectDeps
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectDeps] -> ShowS
$cshowList :: [SelectDeps] -> ShowS
show :: SelectDeps -> String
$cshow :: SelectDeps -> String
showsPrec :: Int -> SelectDeps -> ShowS
$cshowsPrec :: Int -> SelectDeps -> ShowS
Show)

selectDeps :: PrimDarcsOption SelectDeps
selectDeps :: PrimOptSpec DarcsOptDescr Flag a SelectDeps
selectDeps = SelectDeps
-> [RawOptSpec Flag SelectDeps] -> PrimDarcsOption SelectDeps
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault SelectDeps
PromptDeps
  [ String
-> [String]
-> Flag
-> SelectDeps
-> String
-> RawOptSpec Flag SelectDeps
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-deps"] Flag
F.DontGrabDeps SelectDeps
NoDeps
    String
"don't automatically fulfill dependencies"
  , String
-> [String]
-> Flag
-> SelectDeps
-> String
-> RawOptSpec Flag SelectDeps
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"auto-deps",String
"dont-prompt-for-dependencies"] Flag
F.DontPromptForDependencies SelectDeps
AutoDeps
    String
"don't ask about patches that are depended on by matched patches (with --match or --patch)"
  , String
-> [String]
-> Flag
-> SelectDeps
-> String
-> RawOptSpec Flag SelectDeps
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"prompt-deps",String
"prompt-for-dependencies"] Flag
F.PromptForDependencies SelectDeps
PromptDeps
    String
"prompt about patches that are depended on by matched patches" ]

changesReverse :: PrimDarcsOption Bool
changesReverse :: PrimOptSpec DarcsOptDescr Flag a Bool
changesReverse = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"reverse"] Flag
F.Reverse Bool
True String
"show/consider changes in reverse order"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-reverse"] Flag
F.Forward Bool
False String
"show/consider changes in the usual order" ]

maxCount :: PrimDarcsOption (Maybe Int)
maxCount :: PrimOptSpec DarcsOptDescr Flag a (Maybe Int)
maxCount = Maybe Int
-> [RawOptSpec Flag (Maybe Int)] -> PrimDarcsOption (Maybe Int)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe Int
forall a. Maybe a
Nothing
  [ String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Maybe Int)
-> (Maybe Int -> [String])
-> String
-> String
-> RawOptSpec Flag (Maybe Int)
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"max-count"] String -> Flag
F.MaxCount Flag -> [String]
unF String -> Maybe Int
toV Maybe Int -> [String]
unV String
"NUMBER" String
"return only NUMBER results" ]
  where
    unF :: Flag -> [String]
unF Flag
f = [ String
s | F.MaxCount String
s <- [Flag
f] ]
    unV :: Maybe Int -> [String]
unV Maybe Int
x = [ Int -> String
showIntArg Int
n | Just Int
n <- [Maybe Int
x] ]
    toV :: String -> Maybe Int
toV = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> (String -> Int) -> String -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> (Int -> Bool) -> String -> Int
parseIntArg String
"count" (Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>=Int
0)

-- * Local or remote repo

repoDir :: PrimDarcsOption (Maybe String)
repoDir :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
repoDir = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"repodir"] String -> Flag
F.WorkRepoDir Flag -> Maybe String
arg String
"DIRECTORY"
    String
"specify the repository directory in which to run"
  where arg :: Flag -> Maybe String
arg (F.WorkRepoDir String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

-- | This option is for when a new repo gets created. Used for clone, convert
-- import, convert darcs-2, and initialize. For clone and initialize it has the
-- same effect as giving the name as a normal argument.
--
-- The @--repodir@ alias is there for compatibility, should be removed eventually.
--
-- TODO We need a way to deprecate options / option names.
newRepo :: PrimDarcsOption (Maybe String)
newRepo :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
newRepo = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"repo-name",String
"repodir"] String -> Flag
F.NewRepo Flag -> Maybe String
arg String
"DIRECTORY" String
"path of output directory"
  where arg :: Flag -> Maybe String
arg (F.NewRepo String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s; arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

possiblyRemoteRepo :: PrimDarcsOption (Maybe String)
possiblyRemoteRepo :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
possiblyRemoteRepo = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"repo"] String -> Flag
F.WorkRepoUrl Flag -> Maybe String
arg String
"URL"
    String
"specify the repository URL"
  where arg :: Flag -> Maybe String
arg (F.WorkRepoUrl String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

remoteRepos :: PrimDarcsOption RemoteRepos
remoteRepos :: PrimOptSpec DarcsOptDescr Flag a RemoteRepos
remoteRepos = (Iso ([String] -> a) (RemoteRepos -> a)
-> OptSpec DarcsOptDescr Flag a ([String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a RemoteRepos
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso ([String] -> a) (RemoteRepos -> a)
 -> OptSpec DarcsOptDescr Flag a ([String] -> a)
 -> PrimOptSpec DarcsOptDescr Flag a RemoteRepos)
-> (Iso [String] RemoteRepos
    -> Iso ([String] -> a) (RemoteRepos -> a))
-> Iso [String] RemoteRepos
-> OptSpec DarcsOptDescr Flag a ([String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a RemoteRepos
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso [String] RemoteRepos -> Iso ([String] -> a) (RemoteRepos -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) (([String] -> RemoteRepos)
-> (RemoteRepos -> [String]) -> Iso [String] RemoteRepos
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso [String] -> RemoteRepos
fw RemoteRepos -> [String]
bw) (OptSpec DarcsOptDescr Flag a ([String] -> a)
 -> PrimOptSpec DarcsOptDescr Flag a RemoteRepos)
-> OptSpec DarcsOptDescr Flag a ([String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a RemoteRepos
forall a b. (a -> b) -> a -> b
$ String
-> [String]
-> (String -> Flag)
-> ([Flag] -> [String])
-> String
-> String
-> PrimDarcsOption [String]
multiStrArg [] [String
"remote-repo"] String -> Flag
F.RemoteRepo [Flag] -> [String]
mkV String
"URL"
    String
"specify the remote repository URL to work with"
  where mkV :: [Flag] -> [String]
mkV [Flag]
fs = [ String
s | F.RemoteRepo String
s <- [Flag]
fs ]
        fw :: [String] -> RemoteRepos
fw [String]
ss = [String] -> RemoteRepos
RemoteRepos [String]
ss
        bw :: RemoteRepos -> [String]
bw (RemoteRepos [String]
ss) = [String]
ss

notInRemoteFlagName :: String
notInRemoteFlagName :: String
notInRemoteFlagName = String
"not-in-remote"

data NotInRemote
  = NotInDefaultRepo
  | NotInRemotePath String

notInRemote :: PrimDarcsOption [NotInRemote]
notInRemote :: PrimOptSpec DarcsOptDescr Flag a [NotInRemote]
notInRemote = (Iso ([Maybe String] -> a) ([NotInRemote] -> a)
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a [NotInRemote]
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso ([Maybe String] -> a) ([NotInRemote] -> a)
 -> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
 -> PrimOptSpec DarcsOptDescr Flag a [NotInRemote])
-> (Iso [Maybe String] [NotInRemote]
    -> Iso ([Maybe String] -> a) ([NotInRemote] -> a))
-> Iso [Maybe String] [NotInRemote]
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a [NotInRemote]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso [Maybe String] [NotInRemote]
-> Iso ([Maybe String] -> a) ([NotInRemote] -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) (([Maybe String] -> [NotInRemote])
-> ([NotInRemote] -> [Maybe String])
-> Iso [Maybe String] [NotInRemote]
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso ((Maybe String -> NotInRemote) -> [Maybe String] -> [NotInRemote]
forall a b. (a -> b) -> [a] -> [b]
map Maybe String -> NotInRemote
fw) ((NotInRemote -> Maybe String) -> [NotInRemote] -> [Maybe String]
forall a b. (a -> b) -> [a] -> [b]
map NotInRemote -> Maybe String
bw)) (OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
 -> PrimOptSpec DarcsOptDescr Flag a [NotInRemote])
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> PrimOptSpec DarcsOptDescr Flag a [NotInRemote]
forall a b. (a -> b) -> a -> b
$
    String
-> [String]
-> (Maybe String -> Flag)
-> ([Flag] -> [Maybe String])
-> String
-> String
-> PrimDarcsOption [Maybe String]
multiOptStrArg [] [String
notInRemoteFlagName] Maybe String -> Flag
F.NotInRemote [Flag] -> [Maybe String]
args String
"URL/PATH" (String -> PrimDarcsOption [Maybe String])
-> String -> PrimDarcsOption [Maybe String]
forall a b. (a -> b) -> a -> b
$
        String
"select all patches not in the default push/pull repository or at "
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"location URL/PATH"
  where
    args :: [Flag] -> [Maybe String]
args [Flag]
fs = [Maybe String
s | F.NotInRemote Maybe String
s <- [Flag]
fs]
    fw :: Maybe String -> NotInRemote
fw (Just String
s) = String -> NotInRemote
NotInRemotePath String
s
    fw Maybe String
Nothing = NotInRemote
NotInDefaultRepo
    bw :: NotInRemote -> Maybe String
bw (NotInRemotePath String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
    bw NotInRemote
NotInDefaultRepo = Maybe String
forall a. Maybe a
Nothing

data RepoCombinator = Intersection | Union | Complement deriving (RepoCombinator -> RepoCombinator -> Bool
(RepoCombinator -> RepoCombinator -> Bool)
-> (RepoCombinator -> RepoCombinator -> Bool) -> Eq RepoCombinator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepoCombinator -> RepoCombinator -> Bool
$c/= :: RepoCombinator -> RepoCombinator -> Bool
== :: RepoCombinator -> RepoCombinator -> Bool
$c== :: RepoCombinator -> RepoCombinator -> Bool
Eq, Int -> RepoCombinator -> ShowS
[RepoCombinator] -> ShowS
RepoCombinator -> String
(Int -> RepoCombinator -> ShowS)
-> (RepoCombinator -> String)
-> ([RepoCombinator] -> ShowS)
-> Show RepoCombinator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepoCombinator] -> ShowS
$cshowList :: [RepoCombinator] -> ShowS
show :: RepoCombinator -> String
$cshow :: RepoCombinator -> String
showsPrec :: Int -> RepoCombinator -> ShowS
$cshowsPrec :: Int -> RepoCombinator -> ShowS
Show)

repoCombinator :: PrimDarcsOption RepoCombinator
repoCombinator :: PrimOptSpec DarcsOptDescr Flag a RepoCombinator
repoCombinator = RepoCombinator
-> [RawOptSpec Flag RepoCombinator]
-> PrimDarcsOption RepoCombinator
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault RepoCombinator
Union
  [ String
-> [String]
-> Flag
-> RepoCombinator
-> String
-> RawOptSpec Flag RepoCombinator
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"intersection"] Flag
F.Intersection RepoCombinator
Intersection
    String
"take intersection of all repositories"
  , String
-> [String]
-> Flag
-> RepoCombinator
-> String
-> RawOptSpec Flag RepoCombinator
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"union"] Flag
F.Union RepoCombinator
Union
    String
"take union of all repositories"
  , String
-> [String]
-> Flag
-> RepoCombinator
-> String
-> RawOptSpec Flag RepoCombinator
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"complement"] Flag
F.Complement RepoCombinator
Complement
    String
"take complement of repositories (in order listed)" ]

allowUnrelatedRepos :: PrimDarcsOption Bool
allowUnrelatedRepos :: PrimOptSpec DarcsOptDescr Flag a Bool
allowUnrelatedRepos = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"ignore-unrelated-repos"] Flag
F.AllowUnrelatedRepos
  String
"do not check if repositories are unrelated"

justThisRepo :: PrimDarcsOption Bool
justThisRepo :: PrimOptSpec DarcsOptDescr Flag a Bool
justThisRepo = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"just-this-repo"] Flag
F.JustThisRepo
  String
"Limit the check or repair to the current repo"

-- | convert, clone, init
withWorkingDir :: PrimDarcsOption WithWorkingDir
withWorkingDir :: PrimOptSpec DarcsOptDescr Flag a WithWorkingDir
withWorkingDir = WithWorkingDir
-> [RawOptSpec Flag WithWorkingDir]
-> PrimDarcsOption WithWorkingDir
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault WithWorkingDir
WithWorkingDir
  [ String
-> [String]
-> Flag
-> WithWorkingDir
-> String
-> RawOptSpec Flag WithWorkingDir
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"with-working-dir"] Flag
F.UseWorkingDir WithWorkingDir
WithWorkingDir
    String
"Create a working tree (normal repository)"
  , String
-> [String]
-> Flag
-> WithWorkingDir
-> String
-> RawOptSpec Flag WithWorkingDir
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-working-dir"] Flag
F.UseNoWorkingDir WithWorkingDir
NoWorkingDir
    String
"Do not create a working tree (bare repository)" ]

setDefault :: PrimDarcsOption (Maybe Bool)
setDefault :: PrimOptSpec DarcsOptDescr Flag a (Maybe Bool)
setDefault = Maybe Bool
-> [RawOptSpec Flag (Maybe Bool)] -> PrimDarcsOption (Maybe Bool)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe Bool
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe Bool
-> String
-> RawOptSpec Flag (Maybe Bool)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"set-default"] Flag
F.SetDefault (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True) String
"set default repository"
  , String
-> [String]
-> Flag
-> Maybe Bool
-> String
-> RawOptSpec Flag (Maybe Bool)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-set-default"] Flag
F.NoSetDefault (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False) String
"don't set default repository" ]

inheritDefault :: PrimDarcsOption InheritDefault
inheritDefault :: PrimOptSpec DarcsOptDescr Flag a InheritDefault
inheritDefault = InheritDefault
-> [RawOptSpec Flag InheritDefault]
-> PrimDarcsOption InheritDefault
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault InheritDefault
NoInheritDefault
  [ String
-> [String]
-> Flag
-> InheritDefault
-> String
-> RawOptSpec Flag InheritDefault
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"inherit-default"] Flag
F.InheritDefault InheritDefault
YesInheritDefault String
"inherit default repository"
  , String
-> [String]
-> Flag
-> InheritDefault
-> String
-> RawOptSpec Flag InheritDefault
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-inherit-default"] Flag
F.NoInheritDefault InheritDefault
NoInheritDefault String
"don't inherit default repository" ]

-- * Specifying patch meta-data

patchname :: PrimDarcsOption (Maybe String)
patchname :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
patchname = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [Char
'm'] [String
"name"] String -> Flag
F.PatchName Flag -> Maybe String
arg String
"PATCHNAME"
    String
"name of patch"
  where arg :: Flag -> Maybe String
arg (F.PatchName String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

author :: PrimDarcsOption (Maybe String)
author :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
author = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [Char
'A'] [String
"author"] String -> Flag
F.Author Flag -> Maybe String
arg
    String
"EMAIL" String
"specify author id"
  where arg :: Flag -> Maybe String
arg (F.Author String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

data AskLongComment = NoEditLongComment | YesEditLongComment | PromptLongComment
  deriving (AskLongComment -> AskLongComment -> Bool
(AskLongComment -> AskLongComment -> Bool)
-> (AskLongComment -> AskLongComment -> Bool) -> Eq AskLongComment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AskLongComment -> AskLongComment -> Bool
$c/= :: AskLongComment -> AskLongComment -> Bool
== :: AskLongComment -> AskLongComment -> Bool
$c== :: AskLongComment -> AskLongComment -> Bool
Eq, Int -> AskLongComment -> ShowS
[AskLongComment] -> ShowS
AskLongComment -> String
(Int -> AskLongComment -> ShowS)
-> (AskLongComment -> String)
-> ([AskLongComment] -> ShowS)
-> Show AskLongComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AskLongComment] -> ShowS
$cshowList :: [AskLongComment] -> ShowS
show :: AskLongComment -> String
$cshow :: AskLongComment -> String
showsPrec :: Int -> AskLongComment -> ShowS
$cshowsPrec :: Int -> AskLongComment -> ShowS
Show)

askLongComment :: PrimDarcsOption (Maybe AskLongComment)
askLongComment :: PrimOptSpec DarcsOptDescr Flag a (Maybe AskLongComment)
askLongComment = Maybe AskLongComment
-> [RawOptSpec Flag (Maybe AskLongComment)]
-> PrimDarcsOption (Maybe AskLongComment)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe AskLongComment
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe AskLongComment
-> String
-> RawOptSpec Flag (Maybe AskLongComment)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"edit-long-comment"] Flag
F.EditLongComment (AskLongComment -> Maybe AskLongComment
forall a. a -> Maybe a
Just AskLongComment
YesEditLongComment)
    String
"edit the long comment by default"
  , String
-> [String]
-> Flag
-> Maybe AskLongComment
-> String
-> RawOptSpec Flag (Maybe AskLongComment)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"skip-long-comment"] Flag
F.NoEditLongComment (AskLongComment -> Maybe AskLongComment
forall a. a -> Maybe a
Just AskLongComment
NoEditLongComment)
    String
"don't give a long comment"
  , String
-> [String]
-> Flag
-> Maybe AskLongComment
-> String
-> RawOptSpec Flag (Maybe AskLongComment)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"prompt-long-comment"] Flag
F.PromptLongComment (AskLongComment -> Maybe AskLongComment
forall a. a -> Maybe a
Just AskLongComment
PromptLongComment)
    String
"prompt for whether to edit the long comment" ]

keepDate :: PrimDarcsOption Bool
keepDate :: PrimOptSpec DarcsOptDescr Flag a Bool
keepDate = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"keep-date"] Flag
F.KeepDate Bool
True
   String
"keep the date of the original patch"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-keep-date"] Flag
F.NoKeepDate Bool
False
   String
"use the current date for the amended patch" ]

-- record, send
data Logfile = Logfile
  { Logfile -> Maybe AbsolutePath
_logfile :: Maybe AbsolutePath
  , Logfile -> Bool
_rmlogfile :: Bool
  }

logfile :: PrimDarcsOption Logfile
logfile :: PrimOptSpec DarcsOptDescr Flag a Logfile
logfile = Iso (Maybe AbsolutePath -> Bool -> a) (Logfile -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe AbsolutePath -> Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a Logfile
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((Maybe AbsolutePath -> Bool -> a) -> Logfile -> a)
-> ((Logfile -> a) -> Maybe AbsolutePath -> Bool -> a)
-> Iso (Maybe AbsolutePath -> Bool -> a) (Logfile -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Maybe AbsolutePath -> Bool -> a) -> Logfile -> a
forall t. (Maybe AbsolutePath -> Bool -> t) -> Logfile -> t
fw (Logfile -> a) -> Maybe AbsolutePath -> Bool -> a
forall t. (Logfile -> t) -> Maybe AbsolutePath -> Bool -> t
bw) (PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe AbsolutePath)
PrimDarcsOption (Maybe AbsolutePath)
__logfile PrimOptSpec DarcsOptDescr Flag (Bool -> a) (Maybe AbsolutePath)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe AbsolutePath -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Bool -> a)
PrimDarcsOption Bool
__rmlogfile) where
  fw :: (Maybe AbsolutePath -> Bool -> t) -> Logfile -> t
fw Maybe AbsolutePath -> Bool -> t
k (Logfile Maybe AbsolutePath
x Bool
y) = Maybe AbsolutePath -> Bool -> t
k Maybe AbsolutePath
x Bool
y
  bw :: (Logfile -> t) -> Maybe AbsolutePath -> Bool -> t
bw Logfile -> t
k Maybe AbsolutePath
x Bool
y = Logfile -> t
k (Maybe AbsolutePath -> Bool -> Logfile
Logfile Maybe AbsolutePath
x Bool
y)

__logfile :: PrimDarcsOption (Maybe AbsolutePath)
__logfile :: PrimOptSpec DarcsOptDescr Flag a (Maybe AbsolutePath)
__logfile = String
-> [String]
-> (AbsolutePath -> Flag)
-> (Flag -> Maybe AbsolutePath)
-> String
-> String
-> PrimDarcsOption (Maybe AbsolutePath)
singleAbsPathArg [] [String
"logfile"] AbsolutePath -> Flag
F.LogFile Flag -> Maybe AbsolutePath
arg String
"FILE"
    String
"give patch name and comment in file"
  where arg :: Flag -> Maybe AbsolutePath
arg (F.LogFile AbsolutePath
s) = AbsolutePath -> Maybe AbsolutePath
forall a. a -> Maybe a
Just AbsolutePath
s
        arg Flag
_ = Maybe AbsolutePath
forall a. Maybe a
Nothing

__rmlogfile :: PrimDarcsOption Bool
__rmlogfile :: PrimOptSpec DarcsOptDescr Flag a Bool
__rmlogfile = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"delete-logfile"] Flag
F.RmLogFile Bool
True
    String
"delete the logfile when done"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-delete-logfile"] Flag
F.DontRmLogFile Bool
False
    String
"keep the logfile when done" ]

-- * Looking for changes

data LookFor = LookFor
  { LookFor -> LookForAdds
adds :: LookForAdds
  , LookFor -> LookForReplaces
replaces :: LookForReplaces
  , LookFor -> LookForMoves
moves :: LookForMoves
  }

lookfor :: PrimDarcsOption LookFor
lookfor :: PrimOptSpec DarcsOptDescr Flag a LookFor
lookfor = Iso
  (LookForAdds -> LookForReplaces -> LookForMoves -> a)
  (LookFor -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     (LookForAdds -> LookForReplaces -> LookForMoves -> a)
-> PrimOptSpec DarcsOptDescr Flag a LookFor
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((LookForAdds -> LookForReplaces -> LookForMoves -> a)
 -> LookFor -> a)
-> ((LookFor -> a)
    -> LookForAdds -> LookForReplaces -> LookForMoves -> a)
-> Iso
     (LookForAdds -> LookForReplaces -> LookForMoves -> a)
     (LookFor -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (LookForAdds -> LookForReplaces -> LookForMoves -> a)
-> LookFor -> a
forall t.
(LookForAdds -> LookForReplaces -> LookForMoves -> t)
-> LookFor -> t
fw (LookFor -> a)
-> LookForAdds -> LookForReplaces -> LookForMoves -> a
forall t.
(LookFor -> t)
-> LookForAdds -> LookForReplaces -> LookForMoves -> t
bw) (LookForAdds -> PrimDarcsOption LookForAdds
lookforadds LookForAdds
NoLookForAdds PrimOptSpec
  DarcsOptDescr
  Flag
  (LookForReplaces -> LookForMoves -> a)
  LookForAdds
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForMoves -> a)
     (LookForReplaces -> LookForMoves -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForMoves -> a)
     (LookForAdds -> LookForReplaces -> LookForMoves -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (LookForMoves -> a)
  (LookForReplaces -> LookForMoves -> a)
PrimDarcsOption LookForReplaces
lookforreplaces OptSpec
  DarcsOptDescr
  Flag
  (LookForMoves -> a)
  (LookForAdds -> LookForReplaces -> LookForMoves -> a)
-> OptSpec DarcsOptDescr Flag a (LookForMoves -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     (LookForAdds -> LookForReplaces -> LookForMoves -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (LookForMoves -> a)
PrimDarcsOption LookForMoves
lookformoves) where
  fw :: (LookForAdds -> LookForReplaces -> LookForMoves -> t)
-> LookFor -> t
fw LookForAdds -> LookForReplaces -> LookForMoves -> t
k (LookFor LookForAdds
a LookForReplaces
r LookForMoves
m) = LookForAdds -> LookForReplaces -> LookForMoves -> t
k LookForAdds
a LookForReplaces
r LookForMoves
m
  bw :: (LookFor -> t)
-> LookForAdds -> LookForReplaces -> LookForMoves -> t
bw LookFor -> t
k LookForAdds
a LookForReplaces
r LookForMoves
m = LookFor -> t
k (LookForAdds -> LookForReplaces -> LookForMoves -> LookFor
LookFor LookForAdds
a LookForReplaces
r LookForMoves
m)

lookforadds :: LookForAdds -> PrimDarcsOption LookForAdds
lookforadds :: LookForAdds -> PrimDarcsOption LookForAdds
lookforadds LookForAdds
def = LookForAdds
-> [RawOptSpec Flag LookForAdds] -> PrimDarcsOption LookForAdds
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault LookForAdds
def
  [ String
-> [String]
-> Flag
-> LookForAdds
-> String
-> RawOptSpec Flag LookForAdds
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'l'] [String
"look-for-adds"] Flag
F.LookForAdds LookForAdds
YesLookForAdds
    String
"look for (non-boring) files that could be added"
  , String
-> [String]
-> Flag
-> LookForAdds
-> String
-> RawOptSpec Flag LookForAdds
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-look-for-adds",String
"no-look-for-adds"] Flag
F.NoLookForAdds LookForAdds
NoLookForAdds
    String
"don't look for any files that could be added" ]

lookforreplaces :: PrimDarcsOption LookForReplaces
lookforreplaces :: PrimOptSpec DarcsOptDescr Flag a LookForReplaces
lookforreplaces = LookForReplaces
-> [RawOptSpec Flag LookForReplaces]
-> PrimDarcsOption LookForReplaces
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault LookForReplaces
NoLookForReplaces
  [ String
-> [String]
-> Flag
-> LookForReplaces
-> String
-> RawOptSpec Flag LookForReplaces
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"look-for-replaces"] Flag
F.LookForReplaces LookForReplaces
YesLookForReplaces
    String
"look for replaces that could be marked"
  , String
-> [String]
-> Flag
-> LookForReplaces
-> String
-> RawOptSpec Flag LookForReplaces
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-look-for-replaces",String
"no-look-for-replaces"]
    Flag
F.NoLookForReplaces LookForReplaces
NoLookForReplaces
    String
"don't look for any replaces" ]

lookformoves :: PrimDarcsOption LookForMoves
lookformoves :: PrimOptSpec DarcsOptDescr Flag a LookForMoves
lookformoves = LookForMoves
-> [RawOptSpec Flag LookForMoves] -> PrimDarcsOption LookForMoves
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault LookForMoves
NoLookForMoves
  [ String
-> [String]
-> Flag
-> LookForMoves
-> String
-> RawOptSpec Flag LookForMoves
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"look-for-moves"] Flag
F.LookForMoves LookForMoves
YesLookForMoves
   String
"look for files that may be moved/renamed"
  , String
-> [String]
-> Flag
-> LookForMoves
-> String
-> RawOptSpec Flag LookForMoves
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-look-for-moves",String
"no-look-for-moves"]
    Flag
F.NoLookForMoves LookForMoves
NoLookForMoves
   String
"don't look for any files that could be moved/renamed" ]

-- * Files to consider

useIndex :: PrimDarcsOption UseIndex
useIndex :: PrimOptSpec DarcsOptDescr Flag a UseIndex
useIndex = (Iso (Bool -> a) (UseIndex -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a UseIndex
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso (Bool -> a) (UseIndex -> a)
 -> OptSpec DarcsOptDescr Flag a (Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a UseIndex)
-> (Iso Bool UseIndex -> Iso (Bool -> a) (UseIndex -> a))
-> Iso Bool UseIndex
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a UseIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso Bool UseIndex -> Iso (Bool -> a) (UseIndex -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) ((Bool -> UseIndex) -> (UseIndex -> Bool) -> Iso Bool UseIndex
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso Bool -> UseIndex
fw UseIndex -> Bool
bw) OptSpec DarcsOptDescr Flag a (Bool -> a)
PrimDarcsOption Bool
ignoreTimes where
  fw :: Bool -> UseIndex
fw Bool
False = UseIndex
UseIndex
  fw Bool
True = UseIndex
IgnoreIndex
  bw :: UseIndex -> Bool
bw UseIndex
UseIndex = Bool
False
  bw UseIndex
IgnoreIndex = Bool
True

includeBoring :: PrimDarcsOption IncludeBoring
includeBoring :: PrimOptSpec DarcsOptDescr Flag a IncludeBoring
includeBoring = IncludeBoring
-> [RawOptSpec Flag IncludeBoring] -> PrimDarcsOption IncludeBoring
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault IncludeBoring
NoIncludeBoring
  [ String
-> [String]
-> Flag
-> IncludeBoring
-> String
-> RawOptSpec Flag IncludeBoring
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"boring"] Flag
F.Boring IncludeBoring
YesIncludeBoring String
"don't skip boring files"
  , String
-> [String]
-> Flag
-> IncludeBoring
-> String
-> RawOptSpec Flag IncludeBoring
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-boring"] Flag
F.SkipBoring IncludeBoring
NoIncludeBoring String
"skip boring files" ]

allowProblematicFilenames :: DarcsOption a (Bool -> Bool -> a)
allowProblematicFilenames :: DarcsOption a (Bool -> Bool -> a)
allowProblematicFilenames = PrimOptSpec DarcsOptDescr Flag (Bool -> a) Bool
PrimDarcsOption Bool
allowCaseDifferingFilenames PrimOptSpec DarcsOptDescr Flag (Bool -> a) Bool
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> DarcsOption a (Bool -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Bool -> a)
PrimDarcsOption Bool
allowWindowsReservedFilenames

allowCaseDifferingFilenames :: PrimDarcsOption Bool
allowCaseDifferingFilenames :: PrimOptSpec DarcsOptDescr Flag a Bool
allowCaseDifferingFilenames = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"case-ok"] Flag
F.AllowCaseOnly Bool
True
    String
"don't refuse to add files differing only in case"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-case-ok"] Flag
F.DontAllowCaseOnly Bool
False
    String
"refuse to add files whose name differ only in case" ]

allowWindowsReservedFilenames :: PrimDarcsOption Bool
allowWindowsReservedFilenames :: PrimOptSpec DarcsOptDescr Flag a Bool
allowWindowsReservedFilenames = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"reserved-ok"] Flag
F.AllowWindowsReserved Bool
True
    String
"don't refuse to add files with Windows-reserved names"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-reserved-ok"] Flag
F.DontAllowWindowsReserved Bool
False
    String
"refuse to add files with Windows-reserved names" ]

-- | TODO: see issue2395
onlyToFiles :: PrimDarcsOption Bool
onlyToFiles :: PrimOptSpec DarcsOptDescr Flag a Bool
onlyToFiles = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"only-to-files"] Flag
F.OnlyChangesToFiles Bool
True
    String
"show only changes to specified files"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-only-to-files"] Flag
F.ChangesToAllFiles Bool
False
    String
"show changes to all files" ]

ignoreTimes :: PrimDarcsOption Bool
ignoreTimes :: PrimOptSpec DarcsOptDescr Flag a Bool
ignoreTimes = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"ignore-times"] Flag
F.IgnoreTimes Bool
True
    String
"don't trust the file modification times"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-ignore-times"] Flag
F.DontIgnoreTimes Bool
False
    String
"trust modification times to find modified files" ]

recursive :: PrimDarcsOption Bool
recursive :: PrimOptSpec DarcsOptDescr Flag a Bool
recursive = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'r'] [String
"recursive"] Flag
F.Recursive Bool
True String
"recurse into subdirectories"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"not-recursive",String
"no-recursive"] Flag
F.NoRecursive Bool
False (String
"don't recurse into subdirectories") ]

-- * Differences

diffAlgorithm :: PrimDarcsOption DiffAlgorithm
diffAlgorithm :: PrimOptSpec DarcsOptDescr Flag a DiffAlgorithm
diffAlgorithm = DiffAlgorithm
-> [RawOptSpec Flag DiffAlgorithm] -> PrimDarcsOption DiffAlgorithm
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault DiffAlgorithm
PatienceDiff
  [ String
-> [String]
-> Flag
-> DiffAlgorithm
-> String
-> RawOptSpec Flag DiffAlgorithm
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"myers"] Flag
F.UseMyersDiff DiffAlgorithm
MyersDiff
    String
"use myers diff algorithm"
  , String
-> [String]
-> Flag
-> DiffAlgorithm
-> String
-> RawOptSpec Flag DiffAlgorithm
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"patience"] Flag
F.UsePatienceDiff DiffAlgorithm
PatienceDiff
    String
"use patience diff algorithm" ]

data WithContext = NoContext | YesContext deriving (WithContext -> WithContext -> Bool
(WithContext -> WithContext -> Bool)
-> (WithContext -> WithContext -> Bool) -> Eq WithContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithContext -> WithContext -> Bool
$c/= :: WithContext -> WithContext -> Bool
== :: WithContext -> WithContext -> Bool
$c== :: WithContext -> WithContext -> Bool
Eq, Int -> WithContext -> ShowS
[WithContext] -> ShowS
WithContext -> String
(Int -> WithContext -> ShowS)
-> (WithContext -> String)
-> ([WithContext] -> ShowS)
-> Show WithContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithContext] -> ShowS
$cshowList :: [WithContext] -> ShowS
show :: WithContext -> String
$cshow :: WithContext -> String
showsPrec :: Int -> WithContext -> ShowS
$cshowsPrec :: Int -> WithContext -> ShowS
Show)

instance YesNo WithContext where
  yes :: WithContext -> Bool
yes WithContext
NoContext = Bool
False
  yes WithContext
YesContext = Bool
True

withContext :: PrimDarcsOption WithContext
withContext :: PrimOptSpec DarcsOptDescr Flag a WithContext
withContext = (Iso (Bool -> a) (WithContext -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithContext
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso (Bool -> a) (WithContext -> a)
 -> OptSpec DarcsOptDescr Flag a (Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a WithContext)
-> (Iso Bool WithContext -> Iso (Bool -> a) (WithContext -> a))
-> Iso Bool WithContext
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso Bool WithContext -> Iso (Bool -> a) (WithContext -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) ((Bool -> WithContext)
-> (WithContext -> Bool) -> Iso Bool WithContext
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso Bool -> WithContext
fw WithContext -> Bool
bw) (OptSpec DarcsOptDescr Flag a (Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a WithContext)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithContext
forall a b. (a -> b) -> a -> b
$ Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'u'] [String
"unified"] Flag
F.Unified Bool
True
    String
"output changes in a darcs-specific format similar to diff -u"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg  [] [String
"no-unified"] Flag
F.NonUnified Bool
False
    String
"output changes in darcs' usual format" ]
  where fw :: Bool -> WithContext
fw Bool
False = WithContext
NoContext
        fw Bool
True = WithContext
YesContext
        bw :: WithContext -> Bool
bw WithContext
NoContext = Bool
False
        bw WithContext
YesContext = Bool
True

data ExternalDiff = ExternalDiff
  { ExternalDiff -> Maybe String
diffCmd :: Maybe String
  , ExternalDiff -> [String]
diffOpts :: [String]
  , ExternalDiff -> Bool
diffUnified :: Bool
  } deriving (ExternalDiff -> ExternalDiff -> Bool
(ExternalDiff -> ExternalDiff -> Bool)
-> (ExternalDiff -> ExternalDiff -> Bool) -> Eq ExternalDiff
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExternalDiff -> ExternalDiff -> Bool
$c/= :: ExternalDiff -> ExternalDiff -> Bool
== :: ExternalDiff -> ExternalDiff -> Bool
$c== :: ExternalDiff -> ExternalDiff -> Bool
Eq, Int -> ExternalDiff -> ShowS
[ExternalDiff] -> ShowS
ExternalDiff -> String
(Int -> ExternalDiff -> ShowS)
-> (ExternalDiff -> String)
-> ([ExternalDiff] -> ShowS)
-> Show ExternalDiff
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExternalDiff] -> ShowS
$cshowList :: [ExternalDiff] -> ShowS
show :: ExternalDiff -> String
$cshow :: ExternalDiff -> String
showsPrec :: Int -> ExternalDiff -> ShowS
$cshowsPrec :: Int -> ExternalDiff -> ShowS
Show)

extDiff :: PrimDarcsOption ExternalDiff
extDiff :: PrimOptSpec DarcsOptDescr Flag a ExternalDiff
extDiff = Iso (Maybe String -> [String] -> Bool -> a) (ExternalDiff -> a)
-> OptSpec
     DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a ExternalDiff
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((Maybe String -> [String] -> Bool -> a) -> ExternalDiff -> a)
-> ((ExternalDiff -> a) -> Maybe String -> [String] -> Bool -> a)
-> Iso (Maybe String -> [String] -> Bool -> a) (ExternalDiff -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Maybe String -> [String] -> Bool -> a) -> ExternalDiff -> a
forall t.
(Maybe String -> [String] -> Bool -> t) -> ExternalDiff -> t
fw (ExternalDiff -> a) -> Maybe String -> [String] -> Bool -> a
forall t.
(ExternalDiff -> t) -> Maybe String -> [String] -> Bool -> t
bw) (OptSpec
   DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
 -> PrimOptSpec DarcsOptDescr Flag a ExternalDiff)
-> OptSpec
     DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
-> PrimOptSpec DarcsOptDescr Flag a ExternalDiff
forall a b. (a -> b) -> a -> b
$ PrimOptSpec
  DarcsOptDescr Flag ([String] -> Bool -> a) (Maybe String)
PrimDarcsOption (Maybe String)
__extDiffCmd PrimOptSpec
  DarcsOptDescr Flag ([String] -> Bool -> a) (Maybe String)
-> OptSpec DarcsOptDescr Flag (Bool -> a) ([String] -> Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Bool -> a)
     (Maybe String -> [String] -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag (Bool -> a) ([String] -> Bool -> a)
PrimDarcsOption [String]
__extDiffOpts OptSpec
  DarcsOptDescr
  Flag
  (Bool -> a)
  (Maybe String -> [String] -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec
     DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Bool -> a)
PrimDarcsOption Bool
__unidiff where
  fw :: (Maybe String -> [String] -> Bool -> t) -> ExternalDiff -> t
fw Maybe String -> [String] -> Bool -> t
k (ExternalDiff Maybe String
cmd [String]
opts Bool
uni) = Maybe String -> [String] -> Bool -> t
k Maybe String
cmd [String]
opts Bool
uni
  bw :: (ExternalDiff -> t) -> Maybe String -> [String] -> Bool -> t
bw ExternalDiff -> t
k Maybe String
cmd [String]
opts Bool
uni = ExternalDiff -> t
k (Maybe String -> [String] -> Bool -> ExternalDiff
ExternalDiff Maybe String
cmd [String]
opts Bool
uni)

__extDiffCmd :: PrimDarcsOption (Maybe String)
__extDiffCmd :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
__extDiffCmd = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"diff-command"] String -> Flag
F.DiffCmd Flag -> Maybe String
arg String
"COMMAND"
    String
"specify diff command (ignores --diff-opts)"
  where arg :: Flag -> Maybe String
arg (F.DiffCmd String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

__extDiffOpts :: PrimDarcsOption [String]
__extDiffOpts :: PrimOptSpec DarcsOptDescr Flag a [String]
__extDiffOpts = String
-> [String]
-> (String -> Flag)
-> ([Flag] -> [String])
-> String
-> String
-> PrimDarcsOption [String]
multiStrArg [] [String
"diff-opts"] String -> Flag
F.DiffFlags [Flag] -> [String]
mkV String
"OPTIONS"
    String
"options to pass to diff"
  where mkV :: [Flag] -> [String]
mkV [Flag]
fs = [ String
s | F.DiffFlags String
s <- [Flag]
fs ]

__unidiff :: PrimDarcsOption Bool
__unidiff :: PrimOptSpec DarcsOptDescr Flag a Bool
__unidiff = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'u'] [String
"unified"] Flag
F.Unified Bool
True String
"pass -u option to diff"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg  [] [String
"no-unified"] Flag
F.NonUnified Bool
False String
"output patch in diff's dumb format" ]

-- * Runnign tests

data TestChanges = NoTestChanges | YesTestChanges LeaveTestDir deriving (TestChanges -> TestChanges -> Bool
(TestChanges -> TestChanges -> Bool)
-> (TestChanges -> TestChanges -> Bool) -> Eq TestChanges
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestChanges -> TestChanges -> Bool
$c/= :: TestChanges -> TestChanges -> Bool
== :: TestChanges -> TestChanges -> Bool
$c== :: TestChanges -> TestChanges -> Bool
Eq)

testChanges :: PrimDarcsOption TestChanges
testChanges :: PrimOptSpec DarcsOptDescr Flag a TestChanges
testChanges = Iso (RunTest -> LeaveTestDir -> a) (TestChanges -> a)
-> OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
-> PrimOptSpec DarcsOptDescr Flag a TestChanges
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((RunTest -> LeaveTestDir -> a) -> TestChanges -> a)
-> ((TestChanges -> a) -> RunTest -> LeaveTestDir -> a)
-> Iso (RunTest -> LeaveTestDir -> a) (TestChanges -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (RunTest -> LeaveTestDir -> a) -> TestChanges -> a
forall p. (RunTest -> LeaveTestDir -> p) -> TestChanges -> p
fw (TestChanges -> a) -> RunTest -> LeaveTestDir -> a
forall p. (TestChanges -> p) -> RunTest -> LeaveTestDir -> p
bw) (OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
 -> PrimOptSpec DarcsOptDescr Flag a TestChanges)
-> OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
-> PrimOptSpec DarcsOptDescr Flag a TestChanges
forall a b. (a -> b) -> a -> b
$ PrimOptSpec DarcsOptDescr Flag (LeaveTestDir -> a) RunTest
PrimDarcsOption RunTest
runTest PrimOptSpec DarcsOptDescr Flag (LeaveTestDir -> a) RunTest
-> OptSpec DarcsOptDescr Flag a (LeaveTestDir -> a)
-> OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (LeaveTestDir -> a)
PrimDarcsOption LeaveTestDir
leaveTestDir where
  fw :: (RunTest -> LeaveTestDir -> p) -> TestChanges -> p
fw RunTest -> LeaveTestDir -> p
k TestChanges
NoTestChanges = RunTest -> LeaveTestDir -> p
k RunTest
NoRunTest LeaveTestDir
NoLeaveTestDir
  fw RunTest -> LeaveTestDir -> p
k (YesTestChanges LeaveTestDir
ltd) = RunTest -> LeaveTestDir -> p
k RunTest
YesRunTest LeaveTestDir
ltd
  bw :: (TestChanges -> p) -> RunTest -> LeaveTestDir -> p
bw TestChanges -> p
k RunTest
NoRunTest LeaveTestDir
_ = TestChanges -> p
k TestChanges
NoTestChanges
  bw TestChanges -> p
k RunTest
YesRunTest LeaveTestDir
ltd = TestChanges -> p
k (LeaveTestDir -> TestChanges
YesTestChanges LeaveTestDir
ltd)

runTest :: PrimDarcsOption RunTest
runTest :: PrimOptSpec DarcsOptDescr Flag a RunTest
runTest = RunTest -> [RawOptSpec Flag RunTest] -> PrimDarcsOption RunTest
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault RunTest
NoRunTest
  [ String
-> [String] -> Flag -> RunTest -> String -> RawOptSpec Flag RunTest
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"test"] Flag
F.Test RunTest
YesRunTest String
"run the test script"
  , String
-> [String] -> Flag -> RunTest -> String -> RawOptSpec Flag RunTest
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-test"] Flag
F.NoTest RunTest
NoRunTest String
"don't run the test script" ]

leaveTestDir :: PrimDarcsOption LeaveTestDir
leaveTestDir :: PrimOptSpec DarcsOptDescr Flag a LeaveTestDir
leaveTestDir = LeaveTestDir
-> [RawOptSpec Flag LeaveTestDir] -> PrimDarcsOption LeaveTestDir
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault LeaveTestDir
NoLeaveTestDir
  [ String
-> [String]
-> Flag
-> LeaveTestDir
-> String
-> RawOptSpec Flag LeaveTestDir
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"leave-test-directory"]
    Flag
F.LeaveTestDir LeaveTestDir
YesLeaveTestDir String
"don't remove the test directory"
  , String
-> [String]
-> Flag
-> LeaveTestDir
-> String
-> RawOptSpec Flag LeaveTestDir
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"remove-test-directory"]
    Flag
F.NoLeaveTestDir LeaveTestDir
NoLeaveTestDir String
"remove the test directory" ]

-- * Mail related

data HeaderFields = HeaderFields
  { HeaderFields -> [String]
_to, HeaderFields -> [String]
_cc :: [String]
  , HeaderFields -> Maybe String
_from, HeaderFields -> Maybe String
_subject, HeaderFields -> Maybe String
_inReplyTo :: Maybe String
  }

headerFields :: PrimDarcsOption HeaderFields
headerFields :: PrimOptSpec DarcsOptDescr Flag a HeaderFields
headerFields = Iso
  ([String]
   -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
  (HeaderFields -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a HeaderFields
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap ((([String]
  -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
 -> HeaderFields -> a)
-> ((HeaderFields -> a)
    -> [String]
    -> [String]
    -> Maybe String
    -> Maybe String
    -> Maybe String
    -> a)
-> Iso
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
     (HeaderFields -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso ([String]
 -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> HeaderFields -> a
forall t.
([String]
 -> [String] -> Maybe String -> Maybe String -> Maybe String -> t)
-> HeaderFields -> t
fw (HeaderFields -> a)
-> [String]
-> [String]
-> Maybe String
-> Maybe String
-> Maybe String
-> a
forall t.
(HeaderFields -> t)
-> [String]
-> [String]
-> Maybe String
-> Maybe String
-> Maybe String
-> t
bw) (OptSpec
   DarcsOptDescr
   Flag
   a
   ([String]
    -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a HeaderFields)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a HeaderFields
forall a b. (a -> b) -> a -> b
$ PrimOptSpec
  DarcsOptDescr
  Flag
  ([String] -> Maybe String -> Maybe String -> Maybe String -> a)
  [String]
PrimDarcsOption [String]
to PrimOptSpec
  DarcsOptDescr
  Flag
  ([String] -> Maybe String -> Maybe String -> Maybe String -> a)
  [String]
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe String -> Maybe String -> a)
     ([String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe String -> Maybe String -> a)
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe String -> Maybe String -> a)
  ([String] -> Maybe String -> Maybe String -> Maybe String -> a)
PrimDarcsOption [String]
cc OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe String -> Maybe String -> a)
  ([String]
   -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe String -> a)
     (Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe String -> a)
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe String -> a)
  (Maybe String -> Maybe String -> Maybe String -> a)
PrimDarcsOption (Maybe String)
from OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe String -> a)
  ([String]
   -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> a)
     (Maybe String -> Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> a)
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> a)
  (Maybe String -> Maybe String -> a)
PrimDarcsOption (Maybe String)
subject OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> a)
  ([String]
   -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Maybe String -> a)
PrimDarcsOption (Maybe String)
inReplyTo where
  fw :: ([String]
 -> [String] -> Maybe String -> Maybe String -> Maybe String -> t)
-> HeaderFields -> t
fw [String]
-> [String] -> Maybe String -> Maybe String -> Maybe String -> t
k (HeaderFields [String]
t [String]
f Maybe String
c Maybe String
s Maybe String
i) = [String]
-> [String] -> Maybe String -> Maybe String -> Maybe String -> t
k [String]
t [String]
f Maybe String
c Maybe String
s Maybe String
i
  bw :: (HeaderFields -> t)
-> [String]
-> [String]
-> Maybe String
-> Maybe String
-> Maybe String
-> t
bw HeaderFields -> t
k [String]
t [String]
f Maybe String
c Maybe String
s Maybe String
i = HeaderFields -> t
k ([String]
-> [String]
-> Maybe String
-> Maybe String
-> Maybe String
-> HeaderFields
HeaderFields [String]
t [String]
f Maybe String
c Maybe String
s Maybe String
i)

from :: PrimDarcsOption (Maybe String)
from :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
from = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"from"] String -> Flag
F.Author Flag -> Maybe String
arg
    String
"EMAIL" String
"specify email address"
  where arg :: Flag -> Maybe String
arg (F.Author String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

to :: PrimDarcsOption [String]
to :: PrimOptSpec DarcsOptDescr Flag a [String]
to = String
-> [String]
-> (String -> Flag)
-> ([Flag] -> [String])
-> String
-> String
-> PrimDarcsOption [String]
multiStrArg [] [String
"to"] String -> Flag
F.To [Flag] -> [String]
mkV String
"EMAIL" String
"specify destination email"
  where mkV :: [Flag] -> [String]
mkV [Flag]
fs = [ String
s | F.To String
s <- [Flag]
fs ]

cc :: PrimDarcsOption [String]
cc :: PrimOptSpec DarcsOptDescr Flag a [String]
cc = String
-> [String]
-> (String -> Flag)
-> ([Flag] -> [String])
-> String
-> String
-> PrimDarcsOption [String]
multiStrArg [] [String
"cc"] String -> Flag
F.Cc [Flag] -> [String]
mkV String
"EMAIL" String
"mail results to additional EMAIL(s)"
  where mkV :: [Flag] -> [String]
mkV [Flag]
fs = [ String
s | F.Cc String
s <- [Flag]
fs ]

subject :: PrimDarcsOption (Maybe String)
subject :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
subject = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"subject"] String -> Flag
F.Subject Flag -> Maybe String
arg
    String
"SUBJECT" String
"specify mail subject"
  where arg :: Flag -> Maybe String
arg (F.Subject String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

inReplyTo :: PrimDarcsOption (Maybe String)
inReplyTo :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
inReplyTo = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"in-reply-to"] String -> Flag
F.InReplyTo Flag -> Maybe String
arg
    String
"EMAIL" String
"specify in-reply-to header"
  where arg :: Flag -> Maybe String
arg (F.InReplyTo String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

sendToContext :: PrimDarcsOption (Maybe AbsolutePath)
sendToContext :: PrimOptSpec DarcsOptDescr Flag a (Maybe AbsolutePath)
sendToContext = String
-> [String]
-> (AbsolutePath -> Flag)
-> (Flag -> Maybe AbsolutePath)
-> String
-> String
-> PrimDarcsOption (Maybe AbsolutePath)
singleAbsPathArg [] [String
"context"] AbsolutePath -> Flag
F.Context Flag -> Maybe AbsolutePath
arg String
"FILENAME"
    String
"send to context stored in FILENAME"
  where arg :: Flag -> Maybe AbsolutePath
arg (F.Context AbsolutePath
s) = AbsolutePath -> Maybe AbsolutePath
forall a. a -> Maybe a
Just AbsolutePath
s
        arg Flag
_ = Maybe AbsolutePath
forall a. Maybe a
Nothing

-- TODO: do something about the nonsensical case (False, Just s)
--
-- Some of the tests actually do this (pass --sendmail-command without
-- passing --mail) and it's unclear if it's deliberate or just a historical
-- accident after the issue2204 changes. We should untangle that and
-- perhaps turn this into a single option with an optional argument.
-- The other question to resolve is the interaction with the 'output'
-- options to darcs send.
sendmailIso :: Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
sendmailIso :: Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
sendmailIso = ((Bool -> Maybe String -> a) -> (Bool, Maybe String) -> a)
-> (((Bool, Maybe String) -> a) -> Bool -> Maybe String -> a)
-> Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Bool -> Maybe String -> a) -> (Bool, Maybe String) -> a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((Bool, Maybe String) -> a) -> Bool -> Maybe String -> a
forall a b c. ((a, b) -> c) -> a -> b -> c
curry

sendmail :: PrimDarcsOption (Bool, Maybe String)
sendmail :: PrimOptSpec DarcsOptDescr Flag a (Bool, Maybe String)
sendmail = Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a (Bool, Maybe String)
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
forall a.
Iso (Bool -> Maybe String -> a) ((Bool, Maybe String) -> a)
sendmailIso (OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a (Bool, Maybe String))
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a (Bool, Maybe String)
forall a b. (a -> b) -> a -> b
$ PrimOptSpec DarcsOptDescr Flag (Maybe String -> a) Bool
PrimDarcsOption Bool
mail PrimOptSpec DarcsOptDescr Flag (Maybe String -> a) Bool
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Maybe String -> a)
PrimDarcsOption (Maybe String)
sendmailCmd

mail :: PrimDarcsOption Bool
mail :: PrimOptSpec DarcsOptDescr Flag a Bool
mail = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"mail"] Flag
F.Mail String
"send patch using sendmail"

sendmailCmd :: PrimDarcsOption (Maybe String)
sendmailCmd :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
sendmailCmd = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"sendmail-command"] String -> Flag
F.SendmailCmd Flag -> Maybe String
arg String
"COMMAND"
    String
"specify sendmail command"
  where arg :: Flag -> Maybe String
arg (F.SendmailCmd String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

minimize :: PrimDarcsOption Bool
minimize :: PrimOptSpec DarcsOptDescr Flag a Bool
minimize = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"minimize"] Flag
F.Minimize Bool
True String
"minimize context of patch bundle"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-minimize"] Flag
F.NoMinimize Bool
False (String
"don't minimize context of patch bundle") ]

charset :: PrimDarcsOption (Maybe String)
charset :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
charset = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"charset"] String -> Flag
F.Charset Flag -> Maybe String
arg
    String
"CHARSET" String
"specify mail charset"
  where arg :: Flag -> Maybe String
arg (F.Charset String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

editDescription :: PrimDarcsOption Bool
editDescription :: PrimOptSpec DarcsOptDescr Flag a Bool
editDescription = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"edit-description"] Flag
F.EditDescription Bool
True
    String
"edit the patch bundle description"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-edit-description",String
"no-edit-description"] Flag
F.NoEditDescription Bool
False
    String
"don't edit the patch bundle description" ]

-- * Patch bundle related

applyAs :: PrimDarcsOption (Maybe String)
applyAs :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
applyAs = Maybe String
-> [RawOptSpec Flag (Maybe String)]
-> PrimDarcsOption (Maybe String)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe String
forall a. Maybe a
Nothing
  [ String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Maybe String)
-> (Maybe String -> [String])
-> String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"apply-as"] String -> Flag
F.ApplyAs Flag -> [String]
unF String -> Maybe String
forall a. a -> Maybe a
Just Maybe String -> [String]
forall a. Maybe a -> [a]
unV String
"USERNAME"
    String
"apply patch as another user using sudo"
  , String
-> [String]
-> Flag
-> Maybe String
-> String
-> RawOptSpec Flag (Maybe String)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-apply-as"] Flag
F.NonApply Maybe String
forall a. Maybe a
Nothing
    String
"don't use sudo to apply as another user" ]
  where
    unF :: Flag -> [String]
unF Flag
f = [ String
s | F.ApplyAs String
s <- [Flag
f] ]
    unV :: Maybe a -> [a]
unV Maybe a
x = [ a
s | Just a
s <- [Maybe a
x] ]

data Sign = NoSign | Sign | SignAs String | SignSSL String deriving (Sign -> Sign -> Bool
(Sign -> Sign -> Bool) -> (Sign -> Sign -> Bool) -> Eq Sign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sign -> Sign -> Bool
$c/= :: Sign -> Sign -> Bool
== :: Sign -> Sign -> Bool
$c== :: Sign -> Sign -> Bool
Eq, Int -> Sign -> ShowS
[Sign] -> ShowS
Sign -> String
(Int -> Sign -> ShowS)
-> (Sign -> String) -> ([Sign] -> ShowS) -> Show Sign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sign] -> ShowS
$cshowList :: [Sign] -> ShowS
show :: Sign -> String
$cshow :: Sign -> String
showsPrec :: Int -> Sign -> ShowS
$cshowsPrec :: Int -> Sign -> ShowS
Show)

sign :: PrimDarcsOption Sign
sign :: PrimOptSpec DarcsOptDescr Flag a Sign
sign = Sign -> [RawOptSpec Flag Sign] -> PrimDarcsOption Sign
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Sign
NoSign
  [ String
-> [String] -> Flag -> Sign -> String -> RawOptSpec Flag Sign
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"sign"] Flag
F.Sign Sign
Sign String
"sign the patch with your gpg key"
  , String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Sign)
-> (Sign -> [String])
-> String
-> String
-> RawOptSpec Flag Sign
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"sign-as"] String -> Flag
F.SignAs Flag -> [String]
unFSignAs String -> Sign
SignAs Sign -> [String]
unSignAs String
"KEYID"
    String
"sign the patch with a given keyid"
  , String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Sign)
-> (Sign -> [String])
-> String
-> String
-> RawOptSpec Flag Sign
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"sign-ssl"] String -> Flag
F.SignSSL  Flag -> [String]
unFSignSSL String -> Sign
SignSSL Sign -> [String]
unSignSSL String
"IDFILE"
    String
"sign the patch using openssl with a given private key"
  , String
-> [String] -> Flag -> Sign -> String -> RawOptSpec Flag Sign
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-sign",String
"no-sign"] Flag
F.NoSign Sign
NoSign String
"don't sign the patch" ]
  where unFSignAs :: Flag -> [String]
unFSignAs Flag
f = [ String
s | F.SignAs String
s <- [Flag
f] ]
        unSignAs :: Sign -> [String]
unSignAs Sign
v = [ String
s | SignAs String
s <- [Sign
v] ]
        unFSignSSL :: Flag -> [String]
unFSignSSL Flag
f = [ String
s | F.SignSSL String
s <- [Flag
f] ]
        unSignSSL :: Sign -> [String]
unSignSSL Sign
v = [ String
s | SignSSL String
s <- [Sign
v] ]

data Verify = NoVerify | VerifyKeyring AbsolutePath | VerifySSL AbsolutePath deriving (Verify -> Verify -> Bool
(Verify -> Verify -> Bool)
-> (Verify -> Verify -> Bool) -> Eq Verify
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Verify -> Verify -> Bool
$c/= :: Verify -> Verify -> Bool
== :: Verify -> Verify -> Bool
$c== :: Verify -> Verify -> Bool
Eq, Int -> Verify -> ShowS
[Verify] -> ShowS
Verify -> String
(Int -> Verify -> ShowS)
-> (Verify -> String) -> ([Verify] -> ShowS) -> Show Verify
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Verify] -> ShowS
$cshowList :: [Verify] -> ShowS
show :: Verify -> String
$cshow :: Verify -> String
showsPrec :: Int -> Verify -> ShowS
$cshowsPrec :: Int -> Verify -> ShowS
Show)

verify :: PrimDarcsOption Verify
verify :: PrimOptSpec DarcsOptDescr Flag a Verify
verify = Verify -> [RawOptSpec Flag Verify] -> PrimDarcsOption Verify
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Verify
NoVerify
  [ String
-> [String]
-> (AbsolutePath -> Flag)
-> (Flag -> [AbsolutePath])
-> (AbsolutePath -> Verify)
-> (Verify -> [AbsolutePath])
-> String
-> String
-> RawOptSpec Flag Verify
forall f v.
String
-> [String]
-> (AbsolutePath -> f)
-> (f -> [AbsolutePath])
-> (AbsolutePath -> v)
-> (v -> [AbsolutePath])
-> String
-> String
-> RawOptSpec f v
RawAbsPathArg [] [String
"verify"] AbsolutePath -> Flag
F.Verify Flag -> [AbsolutePath]
unFKeyring AbsolutePath -> Verify
VerifyKeyring Verify -> [AbsolutePath]
unVKeyring String
"PUBRING"
    String
"verify that the patch was signed by a key in PUBRING"
  , String
-> [String]
-> (AbsolutePath -> Flag)
-> (Flag -> [AbsolutePath])
-> (AbsolutePath -> Verify)
-> (Verify -> [AbsolutePath])
-> String
-> String
-> RawOptSpec Flag Verify
forall f v.
String
-> [String]
-> (AbsolutePath -> f)
-> (f -> [AbsolutePath])
-> (AbsolutePath -> v)
-> (v -> [AbsolutePath])
-> String
-> String
-> RawOptSpec f v
RawAbsPathArg [] [String
"verify-ssl"] AbsolutePath -> Flag
F.VerifySSL Flag -> [AbsolutePath]
unFSSL AbsolutePath -> Verify
VerifySSL Verify -> [AbsolutePath]
unVSSL String
"KEYS"
    String
"verify using openSSL with authorized keys from file KEYS"
  , String
-> [String] -> Flag -> Verify -> String -> RawOptSpec Flag Verify
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-verify"] Flag
F.NonVerify Verify
NoVerify
    String
"don't verify patch signature" ]
  where
    unFKeyring :: Flag -> [AbsolutePath]
unFKeyring Flag
f = [ AbsolutePath
s | F.Verify AbsolutePath
s <- [Flag
f] ]
    unVKeyring :: Verify -> [AbsolutePath]
unVKeyring Verify
x = [ AbsolutePath
s | VerifyKeyring AbsolutePath
s <- [Verify
x] ]
    unFSSL :: Flag -> [AbsolutePath]
unFSSL Flag
f = [ AbsolutePath
s | F.VerifySSL AbsolutePath
s <- [Flag
f] ]
    unVSSL :: Verify -> [AbsolutePath]
unVSSL Verify
x = [ AbsolutePath
s | VerifySSL AbsolutePath
s <- [Verify
x] ]

-- * Merging patches

-- | push, apply, rebase apply: default to 'NoAllowConflicts'
conflictsNo :: PrimDarcsOption (Maybe AllowConflicts)
conflictsNo :: PrimOptSpec DarcsOptDescr Flag a (Maybe AllowConflicts)
conflictsNo = AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts AllowConflicts
NoAllowConflicts

-- | pull, rebase pull: default to 'YesAllowConflictsAndMark'
conflictsYes :: PrimDarcsOption (Maybe AllowConflicts)
conflictsYes :: PrimOptSpec DarcsOptDescr Flag a (Maybe AllowConflicts)
conflictsYes = AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts AllowConflicts
YesAllowConflictsAndMark

conflicts :: AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts :: AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts AllowConflicts
def = Maybe AllowConflicts
-> [RawOptSpec Flag (Maybe AllowConflicts)]
-> PrimDarcsOption (Maybe AllowConflicts)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault (AllowConflicts -> Maybe AllowConflicts
forall a. a -> Maybe a
Just AllowConflicts
def)
  [ String
-> [String]
-> Flag
-> Maybe AllowConflicts
-> String
-> RawOptSpec Flag (Maybe AllowConflicts)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"mark-conflicts"]
      Flag
F.MarkConflicts (AllowConflicts -> Maybe AllowConflicts
forall a. a -> Maybe a
Just AllowConflicts
YesAllowConflictsAndMark) String
"mark conflicts"
  , String
-> [String]
-> Flag
-> Maybe AllowConflicts
-> String
-> RawOptSpec Flag (Maybe AllowConflicts)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"allow-conflicts"]
      Flag
F.AllowConflicts (AllowConflicts -> Maybe AllowConflicts
forall a. a -> Maybe a
Just AllowConflicts
YesAllowConflicts) String
"allow conflicts, but don't mark them"
  , String
-> [String]
-> Flag
-> Maybe AllowConflicts
-> String
-> RawOptSpec Flag (Maybe AllowConflicts)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-allow-conflicts",String
"no-allow-conflicts",String
"no-resolve-conflicts"]
      Flag
F.NoAllowConflicts (AllowConflicts -> Maybe AllowConflicts
forall a. a -> Maybe a
Just AllowConflicts
NoAllowConflicts) String
"fail if there are patches that would create conflicts"
  , String
-> [String]
-> Flag
-> Maybe AllowConflicts
-> String
-> RawOptSpec Flag (Maybe AllowConflicts)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"skip-conflicts"]
      Flag
F.SkipConflicts Maybe AllowConflicts
forall a. Maybe a
Nothing String
"filter out any patches that would create conflicts" ]

-- Technically not an isomorphism, see 'sendmailIso'.
externalMerge :: PrimDarcsOption ExternalMerge
externalMerge :: PrimOptSpec DarcsOptDescr Flag a ExternalMerge
externalMerge = Iso (Maybe String -> a) (ExternalMerge -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a ExternalMerge
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((Maybe String -> a) -> ExternalMerge -> a)
-> ((ExternalMerge -> a) -> Maybe String -> a)
-> Iso (Maybe String -> a) (ExternalMerge -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Maybe String -> a) -> ExternalMerge -> a
forall p. (Maybe String -> p) -> ExternalMerge -> p
fw (ExternalMerge -> a) -> Maybe String -> a
forall p. (ExternalMerge -> p) -> Maybe String -> p
bw) (OptSpec DarcsOptDescr Flag a (Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a ExternalMerge)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a ExternalMerge
forall a b. (a -> b) -> a -> b
$ String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"external-merge"] String -> Flag
F.ExternalMerge Flag -> Maybe String
arg
    String
"COMMAND" String
"use external tool to merge conflicts"
  where
    arg :: Flag -> Maybe String
arg (F.ExternalMerge String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
    arg Flag
_ = Maybe String
forall a. Maybe a
Nothing
    bw :: (ExternalMerge -> p) -> Maybe String -> p
bw ExternalMerge -> p
k (Just String
s) = ExternalMerge -> p
k (String -> ExternalMerge
YesExternalMerge String
s)
    bw ExternalMerge -> p
k Maybe String
Nothing = ExternalMerge -> p
k ExternalMerge
NoExternalMerge
    fw :: (Maybe String -> p) -> ExternalMerge -> p
fw Maybe String -> p
k (YesExternalMerge String
s) = Maybe String -> p
k (String -> Maybe String
forall a. a -> Maybe a
Just String
s)
    fw Maybe String -> p
k ExternalMerge
NoExternalMerge = Maybe String -> p
k Maybe String
forall a. Maybe a
Nothing

-- | pull, apply, rebase pull, rebase apply
reorder :: PrimDarcsOption Reorder
reorder :: PrimOptSpec DarcsOptDescr Flag a Reorder
reorder = Reorder -> [RawOptSpec Flag Reorder] -> PrimDarcsOption Reorder
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Reorder
NoReorder
  [ String
-> [String] -> Flag -> Reorder -> String -> RawOptSpec Flag Reorder
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"reorder-patches"] Flag
F.Reorder Reorder
Reorder
    String
"put local-only patches on top of remote ones"
  , String
-> [String] -> Flag -> Reorder -> String -> RawOptSpec Flag Reorder
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-reorder-patches"] Flag
F.NoReorder Reorder
NoReorder
    String
"put remote-only patches on top of local ones" ]

-- * Optimizations

compress :: PrimDarcsOption Compression
compress :: PrimOptSpec DarcsOptDescr Flag a Compression
compress = Compression
-> [RawOptSpec Flag Compression] -> PrimDarcsOption Compression
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Compression
GzipCompression
  [ String
-> [String]
-> Flag
-> Compression
-> String
-> RawOptSpec Flag Compression
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"compress"] Flag
F.Compress Compression
GzipCompression String
"compress patch data"
  , String
-> [String]
-> Flag
-> Compression
-> String
-> RawOptSpec Flag Compression
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-compress",String
"no-compress"] Flag
F.NoCompress Compression
NoCompression String
"don't compress patch data" ]

usePacks :: PrimDarcsOption Bool
usePacks :: PrimOptSpec DarcsOptDescr Flag a Bool
usePacks = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"packs"] Flag
F.Packs Bool
True String
"use repository packs"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-packs"] Flag
F.NoPacks Bool
False String
"don't use repository packs" ]

-- for init, clone and convert: patch index disabled by default
patchIndexNo :: PrimDarcsOption WithPatchIndex
patchIndexNo :: PrimOptSpec DarcsOptDescr Flag a WithPatchIndex
patchIndexNo = WithPatchIndex
-> [RawOptSpec Flag WithPatchIndex]
-> PrimDarcsOption WithPatchIndex
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault WithPatchIndex
NoPatchIndex [WithPatchIndex -> RawOptSpec Flag WithPatchIndex
RawDarcsOption
__patchIndex WithPatchIndex
YesPatchIndex, WithPatchIndex -> RawOptSpec Flag WithPatchIndex
RawDarcsOption
__noPatchIndex WithPatchIndex
NoPatchIndex]

-- for log and annotate: patch index enabled by default
patchIndexYes :: PrimDarcsOption WithPatchIndex
patchIndexYes :: PrimOptSpec DarcsOptDescr Flag a WithPatchIndex
patchIndexYes = WithPatchIndex
-> [RawOptSpec Flag WithPatchIndex]
-> PrimDarcsOption WithPatchIndex
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault WithPatchIndex
YesPatchIndex [WithPatchIndex -> RawOptSpec Flag WithPatchIndex
RawDarcsOption
__patchIndex WithPatchIndex
YesPatchIndex, WithPatchIndex -> RawOptSpec Flag WithPatchIndex
RawDarcsOption
__noPatchIndex WithPatchIndex
NoPatchIndex]

__patchIndex, __noPatchIndex :: RawDarcsOption
__patchIndex :: v -> RawOptSpec Flag v
__patchIndex v
val = String -> [String] -> Flag -> v -> String -> RawOptSpec Flag v
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"with-patch-index"] Flag
F.PatchIndexFlag v
val String
"build patch index"
__noPatchIndex :: v -> RawOptSpec Flag v
__noPatchIndex v
val = String -> [String] -> Flag -> v -> String -> RawOptSpec Flag v
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-patch-index"] Flag
F.NoPatchIndexFlag v
val String
"don't build patch index"

-- diff, dist
storeInMemory :: PrimDarcsOption Bool
storeInMemory :: PrimOptSpec DarcsOptDescr Flag a Bool
storeInMemory = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"store-in-memory"] Flag
F.StoreInMemory Bool
True
    String
"do patch application in memory rather than on disk"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-store-in-memory"] Flag
F.ApplyOnDisk Bool
False
    String
"do patch application on disk" ]

-- * Output

data Output = Output AbsolutePathOrStd
            | OutputAutoName AbsolutePath
            deriving (Output -> Output -> Bool
(Output -> Output -> Bool)
-> (Output -> Output -> Bool) -> Eq Output
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Output -> Output -> Bool
$c/= :: Output -> Output -> Bool
== :: Output -> Output -> Bool
$c== :: Output -> Output -> Bool
Eq, Int -> Output -> ShowS
[Output] -> ShowS
Output -> String
(Int -> Output -> ShowS)
-> (Output -> String) -> ([Output] -> ShowS) -> Show Output
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Output] -> ShowS
$cshowList :: [Output] -> ShowS
show :: Output -> String
$cshow :: Output -> String
showsPrec :: Int -> Output -> ShowS
$cshowsPrec :: Int -> Output -> ShowS
Show)

output :: PrimDarcsOption (Maybe Output)
output :: PrimOptSpec DarcsOptDescr Flag a (Maybe Output)
output = Maybe Output
-> [RawOptSpec Flag (Maybe Output)]
-> PrimDarcsOption (Maybe Output)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe Output
forall a. Maybe a
Nothing
    [ String
-> [String]
-> (AbsolutePathOrStd -> Flag)
-> (Flag -> [AbsolutePathOrStd])
-> (AbsolutePathOrStd -> Maybe Output)
-> (Maybe Output -> [AbsolutePathOrStd])
-> String
-> String
-> RawOptSpec Flag (Maybe Output)
forall f v.
String
-> [String]
-> (AbsolutePathOrStd -> f)
-> (f -> [AbsolutePathOrStd])
-> (AbsolutePathOrStd -> v)
-> (v -> [AbsolutePathOrStd])
-> String
-> String
-> RawOptSpec f v
RawAbsPathOrStdArg [Char
'o'] [String
"output"]
      AbsolutePathOrStd -> Flag
F.Output Flag -> [AbsolutePathOrStd]
unOutputF (Output -> Maybe Output
forall a. a -> Maybe a
Just (Output -> Maybe Output)
-> (AbsolutePathOrStd -> Output)
-> AbsolutePathOrStd
-> Maybe Output
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsolutePathOrStd -> Output
Output) Maybe Output -> [AbsolutePathOrStd]
unOutput
      String
"FILE" String
"specify output filename"
    , String
-> [String]
-> (AbsolutePath -> Flag)
-> (Flag -> [AbsolutePath])
-> (AbsolutePath -> Maybe Output)
-> (Maybe Output -> [AbsolutePath])
-> String
-> String
-> String
-> RawOptSpec Flag (Maybe Output)
forall f v.
String
-> [String]
-> (AbsolutePath -> f)
-> (f -> [AbsolutePath])
-> (AbsolutePath -> v)
-> (v -> [AbsolutePath])
-> String
-> String
-> String
-> RawOptSpec f v
RawOptAbsPathArg [Char
'O'] [String
"output-auto-name"]
      AbsolutePath -> Flag
F.OutputAutoName Flag -> [AbsolutePath]
unOutputAutoNameF (Output -> Maybe Output
forall a. a -> Maybe a
Just (Output -> Maybe Output)
-> (AbsolutePath -> Output) -> AbsolutePath -> Maybe Output
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbsolutePath -> Output
OutputAutoName) Maybe Output -> [AbsolutePath]
unOutputAutoName
      String
"." String
"DIRECTORY"
      String
"output to automatically named file in DIRECTORY, default: current directory"
    ]
  where
    unOutputF :: Flag -> [AbsolutePathOrStd]
unOutputF Flag
f = [ AbsolutePathOrStd
p | F.Output AbsolutePathOrStd
p <- [Flag
f] ]
    unOutput :: Maybe Output -> [AbsolutePathOrStd]
unOutput (Just (Output AbsolutePathOrStd
p)) = [AbsolutePathOrStd
p]
    unOutput Maybe Output
_ = []
    unOutputAutoNameF :: Flag -> [AbsolutePath]
unOutputAutoNameF Flag
f = [ AbsolutePath
p | F.OutputAutoName AbsolutePath
p <- [Flag
f] ]
    unOutputAutoName :: Maybe Output -> [AbsolutePath]
unOutputAutoName (Just (OutputAutoName AbsolutePath
p)) = [AbsolutePath
p]
    unOutputAutoName Maybe Output
_ = []

-- * Miscellaneous

data WithSummary = NoSummary | YesSummary deriving (WithSummary -> WithSummary -> Bool
(WithSummary -> WithSummary -> Bool)
-> (WithSummary -> WithSummary -> Bool) -> Eq WithSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithSummary -> WithSummary -> Bool
$c/= :: WithSummary -> WithSummary -> Bool
== :: WithSummary -> WithSummary -> Bool
$c== :: WithSummary -> WithSummary -> Bool
Eq, Int -> WithSummary -> ShowS
[WithSummary] -> ShowS
WithSummary -> String
(Int -> WithSummary -> ShowS)
-> (WithSummary -> String)
-> ([WithSummary] -> ShowS)
-> Show WithSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithSummary] -> ShowS
$cshowList :: [WithSummary] -> ShowS
show :: WithSummary -> String
$cshow :: WithSummary -> String
showsPrec :: Int -> WithSummary -> ShowS
$cshowsPrec :: Int -> WithSummary -> ShowS
Show)

instance YesNo WithSummary where
  yes :: WithSummary -> Bool
yes WithSummary
NoSummary = Bool
False
  yes WithSummary
YesSummary = Bool
True

-- all commands except whatsnew
withSummary :: PrimDarcsOption WithSummary
withSummary :: PrimOptSpec DarcsOptDescr Flag a WithSummary
withSummary = (Iso (Maybe WithSummary -> a) (WithSummary -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithSummary
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso (Maybe WithSummary -> a) (WithSummary -> a)
 -> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
 -> PrimOptSpec DarcsOptDescr Flag a WithSummary)
-> (Iso (Maybe WithSummary) WithSummary
    -> Iso (Maybe WithSummary -> a) (WithSummary -> a))
-> Iso (Maybe WithSummary) WithSummary
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso (Maybe WithSummary) WithSummary
-> Iso (Maybe WithSummary -> a) (WithSummary -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) ((Maybe WithSummary -> WithSummary)
-> (WithSummary -> Maybe WithSummary)
-> Iso (Maybe WithSummary) WithSummary
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso Maybe WithSummary -> WithSummary
fw WithSummary -> Maybe WithSummary
bw) (OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
 -> PrimOptSpec DarcsOptDescr Flag a WithSummary)
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> PrimOptSpec DarcsOptDescr Flag a WithSummary
forall a b. (a -> b) -> a -> b
$ Maybe WithSummary -> PrimDarcsOption (Maybe WithSummary)
maybeSummary Maybe WithSummary
forall a. Maybe a
Nothing
  where
    fw :: Maybe WithSummary -> WithSummary
fw Maybe WithSummary
Nothing = WithSummary
NoSummary
    fw (Just WithSummary
NoSummary) = WithSummary
NoSummary
    fw (Just WithSummary
YesSummary) = WithSummary
YesSummary
    bw :: WithSummary -> Maybe WithSummary
bw WithSummary
NoSummary = Maybe WithSummary
forall a. Maybe a
Nothing
    bw WithSummary
YesSummary = WithSummary -> Maybe WithSummary
forall a. a -> Maybe a
Just WithSummary
YesSummary

-- needed for whatsnew
maybeSummary :: Maybe WithSummary -> PrimDarcsOption (Maybe WithSummary)
maybeSummary :: Maybe WithSummary -> PrimDarcsOption (Maybe WithSummary)
maybeSummary Maybe WithSummary
def = Maybe WithSummary
-> [RawOptSpec Flag (Maybe WithSummary)]
-> PrimDarcsOption (Maybe WithSummary)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe WithSummary
def
  [ String
-> [String]
-> Flag
-> Maybe WithSummary
-> String
-> RawOptSpec Flag (Maybe WithSummary)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
's'] [String
"summary"] Flag
F.Summary (WithSummary -> Maybe WithSummary
forall a. a -> Maybe a
Just WithSummary
YesSummary) String
"summarize changes"
  , String
-> [String]
-> Flag
-> Maybe WithSummary
-> String
-> RawOptSpec Flag (Maybe WithSummary)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-summary"] Flag
F.NoSummary (WithSummary -> Maybe WithSummary
forall a. a -> Maybe a
Just WithSummary
NoSummary) String
"don't summarize changes" ]

-- | TODO: reconsider this grouping of options
data NetworkOptions = NetworkOptions
  { NetworkOptions -> Bool
noHttpPipelining :: Bool
  , NetworkOptions -> RemoteDarcs
remoteDarcs :: RemoteDarcs }

networkIso :: Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
networkIso :: Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
networkIso = ((Bool -> Maybe String -> a) -> NetworkOptions -> a)
-> ((NetworkOptions -> a) -> Bool -> Maybe String -> a)
-> Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Bool -> Maybe String -> a) -> NetworkOptions -> a
forall p. (Bool -> Maybe String -> p) -> NetworkOptions -> p
fw (NetworkOptions -> a) -> Bool -> Maybe String -> a
forall p. (NetworkOptions -> p) -> Bool -> Maybe String -> p
bw where
  fw :: (Bool -> Maybe String -> p) -> NetworkOptions -> p
fw Bool -> Maybe String -> p
k (NetworkOptions Bool
x (RemoteDarcs String
y)) = Bool -> Maybe String -> p
k Bool
x (String -> Maybe String
forall a. a -> Maybe a
Just String
y)
  fw Bool -> Maybe String -> p
k (NetworkOptions Bool
x RemoteDarcs
DefaultRemoteDarcs) = Bool -> Maybe String -> p
k Bool
x Maybe String
forall a. Maybe a
Nothing
  bw :: (NetworkOptions -> p) -> Bool -> Maybe String -> p
bw NetworkOptions -> p
k Bool
x (Just String
y) = NetworkOptions -> p
k (Bool -> RemoteDarcs -> NetworkOptions
NetworkOptions Bool
x (String -> RemoteDarcs
RemoteDarcs String
y))
  bw NetworkOptions -> p
k Bool
x Maybe String
Nothing = NetworkOptions -> p
k (Bool -> RemoteDarcs -> NetworkOptions
NetworkOptions Bool
x RemoteDarcs
DefaultRemoteDarcs)

network :: PrimDarcsOption NetworkOptions
network :: PrimOptSpec DarcsOptDescr Flag a NetworkOptions
network = Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a NetworkOptions
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
forall a. Iso (Bool -> Maybe String -> a) (NetworkOptions -> a)
networkIso
  (OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a NetworkOptions)
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a NetworkOptions
forall a b. (a -> b) -> a -> b
$ String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"no-http-pipelining"] Flag
F.NoHTTPPipelining String
"disable HTTP pipelining"
  PrimOptSpec DarcsOptDescr Flag (Maybe String -> a) Bool
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"remote-darcs"] String -> Flag
F.RemoteDarcsOpt Flag -> Maybe String
arg String
"COMMAND"
    String
"name of the darcs executable on the remote server"
  where arg :: Flag -> Maybe String
arg (F.RemoteDarcsOpt String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

umask :: PrimDarcsOption UMask
umask :: PrimOptSpec DarcsOptDescr Flag a UMask
umask = (Iso (Maybe String -> a) (UMask -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a UMask
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (Iso (Maybe String -> a) (UMask -> a)
 -> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a UMask)
-> (Iso (Maybe String) UMask
    -> Iso (Maybe String -> a) (UMask -> a))
-> Iso (Maybe String) UMask
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a UMask
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso (Maybe String) UMask -> Iso (Maybe String -> a) (UMask -> a)
forall a b c. Iso a b -> Iso (a -> c) (b -> c)
cps) ((Maybe String -> UMask)
-> (UMask -> Maybe String) -> Iso (Maybe String) UMask
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso Maybe String -> UMask
fw UMask -> Maybe String
bw) (OptSpec DarcsOptDescr Flag a (Maybe String -> a)
 -> PrimOptSpec DarcsOptDescr Flag a UMask)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> PrimOptSpec DarcsOptDescr Flag a UMask
forall a b. (a -> b) -> a -> b
$ String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"umask"] String -> Flag
F.UMask Flag -> Maybe String
arg String
"UMASK"
    String
"specify umask to use when writing"
  where
    arg :: Flag -> Maybe String
arg (F.UMask String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
    arg Flag
_ = Maybe String
forall a. Maybe a
Nothing
    fw :: Maybe String -> UMask
fw (Just String
s) = String -> UMask
YesUMask String
s
    fw Maybe String
Nothing = UMask
NoUMask
    bw :: UMask -> Maybe String
bw (YesUMask String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
    bw UMask
NoUMask = Maybe String
forall a. Maybe a
Nothing

setScriptsExecutable :: PrimDarcsOption SetScriptsExecutable
setScriptsExecutable :: PrimOptSpec DarcsOptDescr Flag a SetScriptsExecutable
setScriptsExecutable = SetScriptsExecutable
-> [RawOptSpec Flag SetScriptsExecutable]
-> PrimDarcsOption SetScriptsExecutable
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault SetScriptsExecutable
NoSetScriptsExecutable
  [ String
-> [String]
-> Flag
-> SetScriptsExecutable
-> String
-> RawOptSpec Flag SetScriptsExecutable
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"set-scripts-executable"] Flag
F.SetScriptsExecutable SetScriptsExecutable
YesSetScriptsExecutable
    String
"make scripts executable"
  , String
-> [String]
-> Flag
-> SetScriptsExecutable
-> String
-> RawOptSpec Flag SetScriptsExecutable
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"dont-set-scripts-executable",String
"no-set-scripts-executable"]
    Flag
F.DontSetScriptsExecutable SetScriptsExecutable
NoSetScriptsExecutable String
"don't make scripts executable" ]

-- * Specific to a single command

-- ** amend

amendUnrecord :: PrimDarcsOption Bool
amendUnrecord :: PrimOptSpec DarcsOptDescr Flag a Bool
amendUnrecord = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"unrecord"] Flag
F.AmendUnrecord Bool
True String
"remove changes from the patch"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"record"] Flag
F.NoAmendUnrecord Bool
False String
"add more changes to the patch" ]

selectAuthor :: PrimDarcsOption Bool
selectAuthor :: PrimOptSpec DarcsOptDescr Flag a Bool
selectAuthor = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"select-author"] Flag
F.SelectAuthor
  String
"select author id from a menu"

-- ** annotate

machineReadable :: PrimDarcsOption Bool
machineReadable :: PrimOptSpec DarcsOptDescr Flag a Bool
machineReadable = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ Bool -> RawOptSpec Flag Bool
RawDarcsOption
__humanReadable Bool
False
  , Bool -> RawOptSpec Flag Bool
RawDarcsOption
__machineReadable Bool
True ]

__humanReadable :: RawDarcsOption
__humanReadable :: v -> RawOptSpec Flag v
__humanReadable v
val = String -> [String] -> Flag -> v -> String -> RawOptSpec Flag v
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"human-readable"] Flag
F.HumanReadable v
val String
"normal human-readable output"

__machineReadable :: RawDarcsOption
__machineReadable :: v -> RawOptSpec Flag v
__machineReadable v
val = String -> [String] -> Flag -> v -> String -> RawOptSpec Flag v
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"machine-readable"] Flag
F.MachineReadable v
val String
"machine-readable output"

-- ** clone

cloneKind :: PrimDarcsOption CloneKind
cloneKind :: PrimOptSpec DarcsOptDescr Flag a CloneKind
cloneKind = CloneKind
-> [RawOptSpec Flag CloneKind] -> PrimDarcsOption CloneKind
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault CloneKind
NormalClone
  [ String
-> [String]
-> Flag
-> CloneKind
-> String
-> RawOptSpec Flag CloneKind
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"lazy"] Flag
F.Lazy CloneKind
LazyClone String
"get patch files only as needed"
  , String
-> [String]
-> Flag
-> CloneKind
-> String
-> RawOptSpec Flag CloneKind
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"complete"] Flag
F.Complete CloneKind
CompleteClone String
"get a complete copy of the repository" ]

-- ** convert import/export

marks :: DarcsOption a (Maybe String -> Maybe String -> a)
marks :: DarcsOption a (Maybe String -> Maybe String -> a)
marks = PrimOptSpec DarcsOptDescr Flag (Maybe String -> a) (Maybe String)
PrimDarcsOption (Maybe String)
readMarks PrimOptSpec DarcsOptDescr Flag (Maybe String -> a) (Maybe String)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> DarcsOption a (Maybe String -> Maybe String -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Maybe String -> a)
PrimDarcsOption (Maybe String)
writeMarks

readMarks :: PrimDarcsOption (Maybe String)
readMarks :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
readMarks = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"read-marks"] String -> Flag
F.ReadMarks Flag -> Maybe String
arg
    String
"FILE" String
"continue conversion, previously checkpointed by --write-marks"
  where arg :: Flag -> Maybe String
arg (F.ReadMarks String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

writeMarks :: PrimDarcsOption (Maybe String)
writeMarks :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
writeMarks = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"write-marks"] String -> Flag
F.WriteMarks Flag -> Maybe String
arg
    String
"FILE" String
"checkpoint conversion to continue it later"
  where arg :: Flag -> Maybe String
arg (F.WriteMarks String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

-- | Deprecated flag, still present to output an error message.
hashed :: PrimDarcsOption ()
hashed :: PrimOptSpec DarcsOptDescr Flag a ()
hashed = [String] -> [RawOptSpec Flag ()] -> PrimDarcsOption ()
forall v. [String] -> [RawOptSpec Flag v] -> PrimDarcsOption ()
deprecated
  [ String
"All repositories are now \"hashed\", so this option was removed."
  , String
"Use --darcs-1 to get the effect that --hashed had previously." ] ([RawOptSpec Flag ()] -> PrimDarcsOption ())
-> [RawOptSpec Flag ()] -> PrimDarcsOption ()
forall a b. (a -> b) -> a -> b
$
  [ String -> [String] -> Flag -> () -> String -> RawOptSpec Flag ()
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"hashed"] Flag
F.Hashed () String
"deprecated, use --darcs-1 instead" ]

patchFormat :: PrimDarcsOption PatchFormat
patchFormat :: PrimOptSpec DarcsOptDescr Flag a PatchFormat
patchFormat = PatchFormat
-> [RawOptSpec Flag PatchFormat] -> PrimDarcsOption PatchFormat
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault PatchFormat
PatchFormat2
  [ String
-> [String]
-> Flag
-> PatchFormat
-> String
-> RawOptSpec Flag PatchFormat
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"darcs-3"] Flag
F.UseFormat3 PatchFormat
PatchFormat3
    String
"New darcs patch format"
  , String
-> [String]
-> Flag
-> PatchFormat
-> String
-> RawOptSpec Flag PatchFormat
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"darcs-2"] Flag
F.UseFormat2 PatchFormat
PatchFormat2
    String
"Standard darcs patch format"
  , String
-> [String]
-> Flag
-> PatchFormat
-> String
-> RawOptSpec Flag PatchFormat
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"darcs-1"] Flag
F.UseFormat1 PatchFormat
PatchFormat1
    String
"Older patch format (for compatibility)" ]

-- ** dist

distname :: PrimDarcsOption (Maybe String)
distname :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
distname = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [Char
'd'] [String
"dist-name"] String -> Flag
F.DistName Flag -> Maybe String
arg String
"DISTNAME" String
"name of version"
  where arg :: Flag -> Maybe String
arg (F.DistName String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s
        arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

distzip :: PrimDarcsOption Bool
distzip :: PrimOptSpec DarcsOptDescr Flag a Bool
distzip = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"zip"] Flag
F.DistZip String
"generate zip archive instead of gzip'ed tar"

-- ** log

data ChangesFormat
  = HumanReadable
  | MachineReadable
  | GenContext
  | GenXml
  | NumberPatches
  | CountPatches
  deriving (ChangesFormat -> ChangesFormat -> Bool
(ChangesFormat -> ChangesFormat -> Bool)
-> (ChangesFormat -> ChangesFormat -> Bool) -> Eq ChangesFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangesFormat -> ChangesFormat -> Bool
$c/= :: ChangesFormat -> ChangesFormat -> Bool
== :: ChangesFormat -> ChangesFormat -> Bool
$c== :: ChangesFormat -> ChangesFormat -> Bool
Eq, Int -> ChangesFormat -> ShowS
[ChangesFormat] -> ShowS
ChangesFormat -> String
(Int -> ChangesFormat -> ShowS)
-> (ChangesFormat -> String)
-> ([ChangesFormat] -> ShowS)
-> Show ChangesFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangesFormat] -> ShowS
$cshowList :: [ChangesFormat] -> ShowS
show :: ChangesFormat -> String
$cshow :: ChangesFormat -> String
showsPrec :: Int -> ChangesFormat -> ShowS
$cshowsPrec :: Int -> ChangesFormat -> ShowS
Show)

changesFormat :: PrimDarcsOption (Maybe ChangesFormat)
changesFormat :: PrimOptSpec DarcsOptDescr Flag a (Maybe ChangesFormat)
changesFormat = Maybe ChangesFormat
-> [RawOptSpec Flag (Maybe ChangesFormat)]
-> PrimDarcsOption (Maybe ChangesFormat)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe ChangesFormat
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe ChangesFormat
-> String
-> RawOptSpec Flag (Maybe ChangesFormat)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"context"] Flag
F.GenContext (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
GenContext) String
"produce output suitable for clone --context"
  , Maybe ChangesFormat -> RawOptSpec Flag (Maybe ChangesFormat)
RawDarcsOption
__xmloutput (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
GenXml)
  , Maybe ChangesFormat -> RawOptSpec Flag (Maybe ChangesFormat)
RawDarcsOption
__humanReadable (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
HumanReadable)
  , Maybe ChangesFormat -> RawOptSpec Flag (Maybe ChangesFormat)
RawDarcsOption
__machineReadable (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
MachineReadable)
  , String
-> [String]
-> Flag
-> Maybe ChangesFormat
-> String
-> RawOptSpec Flag (Maybe ChangesFormat)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"number"] Flag
F.NumberPatches (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
NumberPatches) String
"number the changes"
  , String
-> [String]
-> Flag
-> Maybe ChangesFormat
-> String
-> RawOptSpec Flag (Maybe ChangesFormat)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"count"] Flag
F.Count (ChangesFormat -> Maybe ChangesFormat
forall a. a -> Maybe a
Just ChangesFormat
CountPatches) String
"output count of changes" ]

-- ** replace

tokens :: PrimDarcsOption (Maybe String)
tokens :: PrimOptSpec DarcsOptDescr Flag a (Maybe String)
tokens = String
-> [String]
-> (String -> Flag)
-> (Flag -> Maybe String)
-> String
-> String
-> PrimDarcsOption (Maybe String)
singleStrArg [] [String
"token-chars"] String -> Flag
F.Toks Flag -> Maybe String
arg String
"\"[CHARS]\""
    String
"define token to contain these characters"
  where arg :: Flag -> Maybe String
arg (F.Toks String
s) = String -> Maybe String
forall a. a -> Maybe a
Just String
s; arg Flag
_ = Maybe String
forall a. Maybe a
Nothing

forceReplace :: PrimDarcsOption Bool
forceReplace :: PrimOptSpec DarcsOptDescr Flag a Bool
forceReplace = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
False
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [Char
'f'] [String
"force"] Flag
F.ForceReplace Bool
True
    String
"proceed with replace even if 'new' token already exists"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-force"] Flag
F.NonForce Bool
False
    String
"don't force the replace if it looks scary" ]

-- ** test

data TestStrategy = Once | Linear | Backoff | Bisect deriving (TestStrategy -> TestStrategy -> Bool
(TestStrategy -> TestStrategy -> Bool)
-> (TestStrategy -> TestStrategy -> Bool) -> Eq TestStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestStrategy -> TestStrategy -> Bool
$c/= :: TestStrategy -> TestStrategy -> Bool
== :: TestStrategy -> TestStrategy -> Bool
$c== :: TestStrategy -> TestStrategy -> Bool
Eq, Int -> TestStrategy -> ShowS
[TestStrategy] -> ShowS
TestStrategy -> String
(Int -> TestStrategy -> ShowS)
-> (TestStrategy -> String)
-> ([TestStrategy] -> ShowS)
-> Show TestStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestStrategy] -> ShowS
$cshowList :: [TestStrategy] -> ShowS
show :: TestStrategy -> String
$cshow :: TestStrategy -> String
showsPrec :: Int -> TestStrategy -> ShowS
$cshowsPrec :: Int -> TestStrategy -> ShowS
Show)

testStrategy :: PrimDarcsOption TestStrategy
testStrategy :: PrimOptSpec DarcsOptDescr Flag a TestStrategy
testStrategy = TestStrategy
-> [RawOptSpec Flag TestStrategy] -> PrimDarcsOption TestStrategy
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault TestStrategy
Once
  [ String
-> [String]
-> Flag
-> TestStrategy
-> String
-> RawOptSpec Flag TestStrategy
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"once"] Flag
F.Once TestStrategy
Once String
"run test on current version only"
  , String
-> [String]
-> Flag
-> TestStrategy
-> String
-> RawOptSpec Flag TestStrategy
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"linear"] Flag
F.Linear TestStrategy
Linear String
"locate the most recent version lacking an error"
  , String
-> [String]
-> Flag
-> TestStrategy
-> String
-> RawOptSpec Flag TestStrategy
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"backoff"] Flag
F.Backoff TestStrategy
Backoff String
"exponential backoff search"
  , String
-> [String]
-> Flag
-> TestStrategy
-> String
-> RawOptSpec Flag TestStrategy
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"bisect"] Flag
F.Bisect TestStrategy
Bisect String
"binary instead of linear search" ]

-- ** show files

files :: PrimDarcsOption Bool
files :: PrimOptSpec DarcsOptDescr Flag a Bool
files = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"files"] Flag
F.Files Bool
True String
"include files in output"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-files"] Flag
F.NoFiles Bool
False String
"don't include files in output" ]

directories :: PrimDarcsOption Bool
directories :: PrimOptSpec DarcsOptDescr Flag a Bool
directories = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"directories"] Flag
F.Directories Bool
True String
"include directories in output"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-directories"] Flag
F.NoDirectories Bool
False String
"don't include directories in output" ]

pending :: PrimDarcsOption Bool
pending :: PrimOptSpec DarcsOptDescr Flag a Bool
pending = Bool -> [RawOptSpec Flag Bool] -> PrimDarcsOption Bool
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Bool
True
  [ String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"pending"] Flag
F.Pending Bool
True String
"reflect pending patches in output"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-pending"] Flag
F.NoPending Bool
False String
"only include recorded patches in output" ]

-- "null" is already taken
nullFlag :: PrimDarcsOption Bool
nullFlag :: PrimOptSpec DarcsOptDescr Flag a Bool
nullFlag = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [Char
'0'] [String
"null"] Flag
F.NullFlag String
"separate file names by NUL characters"

-- ** show repo

enumPatches :: PrimDarcsOption EnumPatches
enumPatches :: PrimOptSpec DarcsOptDescr Flag a EnumPatches
enumPatches = EnumPatches
-> [RawOptSpec Flag EnumPatches] -> PrimDarcsOption EnumPatches
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault EnumPatches
YesEnumPatches
  [ String
-> [String]
-> Flag
-> EnumPatches
-> String
-> RawOptSpec Flag EnumPatches
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"enum-patches"] Flag
F.EnumPatches EnumPatches
YesEnumPatches
    String
"include statistics requiring enumeration of patches"
  , String
-> [String]
-> Flag
-> EnumPatches
-> String
-> RawOptSpec Flag EnumPatches
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-enum-patches"] Flag
F.NoEnumPatches EnumPatches
NoEnumPatches
    String
"don't include statistics requiring enumeration of patches" ]

-- ** gzcrcs

data GzcrcsAction = GzcrcsCheck | GzcrcsRepair deriving (GzcrcsAction -> GzcrcsAction -> Bool
(GzcrcsAction -> GzcrcsAction -> Bool)
-> (GzcrcsAction -> GzcrcsAction -> Bool) -> Eq GzcrcsAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GzcrcsAction -> GzcrcsAction -> Bool
$c/= :: GzcrcsAction -> GzcrcsAction -> Bool
== :: GzcrcsAction -> GzcrcsAction -> Bool
$c== :: GzcrcsAction -> GzcrcsAction -> Bool
Eq, Int -> GzcrcsAction -> ShowS
[GzcrcsAction] -> ShowS
GzcrcsAction -> String
(Int -> GzcrcsAction -> ShowS)
-> (GzcrcsAction -> String)
-> ([GzcrcsAction] -> ShowS)
-> Show GzcrcsAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GzcrcsAction] -> ShowS
$cshowList :: [GzcrcsAction] -> ShowS
show :: GzcrcsAction -> String
$cshow :: GzcrcsAction -> String
showsPrec :: Int -> GzcrcsAction -> ShowS
$cshowsPrec :: Int -> GzcrcsAction -> ShowS
Show)

gzcrcsActions :: PrimDarcsOption (Maybe GzcrcsAction)
gzcrcsActions :: PrimOptSpec DarcsOptDescr Flag a (Maybe GzcrcsAction)
gzcrcsActions = Maybe GzcrcsAction
-> [RawOptSpec Flag (Maybe GzcrcsAction)]
-> PrimDarcsOption (Maybe GzcrcsAction)
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault Maybe GzcrcsAction
forall a. Maybe a
Nothing
  [ String
-> [String]
-> Flag
-> Maybe GzcrcsAction
-> String
-> RawOptSpec Flag (Maybe GzcrcsAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"check"] Flag
F.Check (GzcrcsAction -> Maybe GzcrcsAction
forall a. a -> Maybe a
Just GzcrcsAction
GzcrcsCheck) String
"Specify checking mode"
  , String
-> [String]
-> Flag
-> Maybe GzcrcsAction
-> String
-> RawOptSpec Flag (Maybe GzcrcsAction)
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"repair"] Flag
F.Repair (GzcrcsAction -> Maybe GzcrcsAction
forall a. a -> Maybe a
Just GzcrcsAction
GzcrcsRepair) String
"Specify repair mode" ]

-- ** optimize

siblings :: PrimDarcsOption [AbsolutePath]
siblings :: PrimOptSpec DarcsOptDescr Flag a [AbsolutePath]
siblings = String
-> [String]
-> (AbsolutePath -> Flag)
-> ([Flag] -> [AbsolutePath])
-> String
-> String
-> PrimDarcsOption [AbsolutePath]
multiAbsPathArg [] [String
"sibling"] AbsolutePath -> Flag
F.Sibling [Flag] -> [AbsolutePath]
mkV String
"DIRECTORY"
    String
"specify a sibling directory"
  where mkV :: [Flag] -> [AbsolutePath]
mkV [Flag]
fs = [ AbsolutePath
s | F.Sibling AbsolutePath
s <- [Flag]
fs ]