{- | 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 (..)
    , HookConfig (..)
    , 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
    , possiblyRemoteRepo
    , newRepo
    , NotInRemote (..)
    , notInRemote
    , notInRemoteFlagName
    , RepoCombinator (..)
    , repoCombinator
    , allowUnrelatedRepos
    , justThisRepo
    , WithWorkingDir (..) -- re-export
    , withWorkingDir
    , SetDefault (..) -- re-export
    , setDefault
    , InheritDefault (..) -- re-export
    , inheritDefault
    , WithPrefsTemplates (..) -- re-export
    , withPrefsTemplates

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

    -- looking for changes
    , UseIndex (..) -- re-export
    , includeBoring
    , LookForAdds (..) -- re-export
    , LookForMoves (..) -- re-export
    , LookForReplaces (..) -- re-export
    , DiffOpts (..)
    , lookforadds
    , maybelookforadds
    , lookforreplaces
    , lookformoves

    -- files to consider
    , allowProblematicFilenames
    , allowCaseDifferingFilenames
    , allowWindowsReservedFilenames
    , onlyToFiles
    , useIndex
    , recursive

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

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

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

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

    -- merging patches
    , AllowConflicts (..) -- re-export
    , conflictsNo
    , conflictsYes
    , ResolveConflicts (..) -- re-export
    , reorder
    , reorderPush

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

    -- miscellaneous
    , Output (..)
    , output
    , WithSummary (..)
    , withSummary
    , maybeSummary
    , RemoteDarcs (..) -- re-export
    , remoteDarcs
    , 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
    , ShrinkFailure (..)
    , shrinkFailure

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

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

    -- gzcrcs
    , GzcrcsAction (..)
    , gzcrcsActions

    -- optimize
    , siblings
    ) where

import Darcs.Prelude

import Darcs.Repository.Flags
    ( RemoteDarcs (..)
    , Reorder (..)
    , Verbosity (..)
    , UseCache (..)
    , UMask (..)
    , DryRun (..)
    , LookForAdds (..)
    , LookForMoves (..)
    , LookForReplaces (..)
    , DiffAlgorithm (..)
    , DiffOpts (..)
    , RunTest (..)
    , SetScriptsExecutable (..)
    , LeaveTestDir (..)
    , SetDefault (..)
    , InheritDefault (..)
    , UseIndex (..)
    , CloneKind (..)
    , AllowConflicts (..)
    , ResolveConflicts (..)
    , WantGuiPause (..)
    , WithPatchIndex (..)
    , WithWorkingDir (..)
    , PatchFormat (..)
    , WithPrefsTemplates(..)
    , OptimizeDeep(..)
    )

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.
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
  yes LookForAdds
EvenLookForBoring = 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 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
$c== :: EnumPatches -> EnumPatches -> Bool
== :: EnumPatches -> EnumPatches -> Bool
$c/= :: EnumPatches -> EnumPatches -> Bool
/= :: 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
$cshowsPrec :: Int -> EnumPatches -> ShowS
showsPrec :: Int -> EnumPatches -> ShowS
$cshow :: EnumPatches -> String
show :: EnumPatches -> String
$cshowList :: [EnumPatches] -> ShowS
showList :: [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

instance YesNo WithPrefsTemplates where
  yes :: WithPrefsTemplates -> Bool
yes WithPrefsTemplates
NoPrefsTemplates = Bool
False
  yes WithPrefsTemplates
WithPrefsTemplates = 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
$c== :: RootAction -> RootAction -> Bool
== :: RootAction -> RootAction -> Bool
$c/= :: RootAction -> RootAction -> Bool
/= :: 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
$cshowsPrec :: Int -> RootAction -> ShowS
showsPrec :: Int -> RootAction -> ShowS
$cshow :: RootAction -> String
show :: RootAction -> String
$cshowList :: [RootAction] -> ShowS
showList :: [RootAction] -> ShowS
Show)

rootActions :: PrimDarcsOption (Maybe RootAction)
rootActions :: PrimDarcsOption (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
$c== :: StdCmdAction -> StdCmdAction -> Bool
== :: StdCmdAction -> StdCmdAction -> Bool
$c/= :: StdCmdAction -> StdCmdAction -> Bool
/= :: 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
$cshowsPrec :: Int -> StdCmdAction -> ShowS
showsPrec :: Int -> StdCmdAction -> ShowS
$cshow :: StdCmdAction -> String
show :: StdCmdAction -> String
$cshowList :: [StdCmdAction] -> ShowS
showList :: [StdCmdAction] -> ShowS
Show)

stdCmdActions :: PrimDarcsOption (Maybe StdCmdAction)
stdCmdActions :: PrimDarcsOption (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 :: PrimDarcsOption Bool
debug = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"debug"] Flag
F.Debug String
"enable general debug output"

verbosity :: PrimDarcsOption Verbosity
verbosity :: PrimDarcsOption 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 :: PrimDarcsOption Bool
timings = String -> [String] -> Flag -> String -> PrimDarcsOption Bool
singleNoArg [] [String
"timings"] Flag
F.Timings String
"provide debugging timings information"

debugging :: DarcsOption a (Bool -> Bool -> a)
debugging :: forall a. DarcsOption a (Bool -> Bool -> a)
debugging = PrimOptSpec DarcsOptDescr Flag (Bool -> a) Bool
PrimDarcsOption Bool
debug PrimOptSpec DarcsOptDescr Flag (Bool -> a) Bool
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag 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
timings

-- ** Hooks

data HooksConfig = HooksConfig
  { HooksConfig -> HookConfig
pre :: HookConfig
  , HooksConfig -> HookConfig
post :: HookConfig
  }

data HookConfig = HookConfig
  { HookConfig -> Maybe String
cmd :: Maybe String
  , HookConfig -> Bool
prompt :: Bool
  }

hooks :: DarcsOption a (HooksConfig -> a)
hooks :: forall a. DarcsOption a (HooksConfig -> a)
hooks = Iso (HookConfig -> HookConfig -> a) (HooksConfig -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (HooksConfig -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (HooksConfig -> a))
-> OptSpec DarcsOptDescr Flag a (HookConfig -> HookConfig -> a)
-> OptSpec DarcsOptDescr Flag 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 :: forall a. 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 :: forall a. DarcsOption a (HookConfig -> a)
preHook = Iso (Maybe String -> Bool -> a) (HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (HookConfig -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> OptSpec DarcsOptDescr Flag 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 :: forall a. DarcsOption a (HookConfig -> a)
postHook = Iso (Maybe String -> Bool -> a) (HookConfig -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (HookConfig -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (HookConfig -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> Bool -> a)
-> OptSpec DarcsOptDescr Flag 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 :: PrimDarcsOption (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 :: PrimDarcsOption (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 :: PrimDarcsOption UseCache
useCache = (Iso (Bool -> a) (UseCache -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (UseCache -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (UseCache -> a))
-> (Iso Bool UseCache -> Iso (Bool -> a) (UseCache -> a))
-> Iso Bool UseCache
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (UseCache -> a)
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)
 -> OptSpec DarcsOptDescr Flag a (UseCache -> a))
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (UseCache -> a)
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
$c== :: XmlOutput -> XmlOutput -> Bool
== :: XmlOutput -> XmlOutput -> Bool
$c/= :: XmlOutput -> XmlOutput -> Bool
/= :: 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
$cshowsPrec :: Int -> XmlOutput -> ShowS
showsPrec :: Int -> XmlOutput -> ShowS
$cshow :: XmlOutput -> String
show :: XmlOutput -> String
$cshowList :: [XmlOutput] -> ShowS
showList :: [XmlOutput] -> ShowS
Show)

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

xmlOutput :: PrimDarcsOption XmlOutput
xmlOutput :: PrimDarcsOption 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 :: RawDarcsOption
__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 :: PrimDarcsOption 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 [Char
'n'] [String
"dry-run"] Flag
F.DryRun DryRun
YesDryRun String
"don't actually take the action" ]

dryRunXml :: DarcsOption a (DryRun -> XmlOutput -> a)
dryRunXml :: forall a. 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)
-> OptSpec DarcsOptDescr Flag 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 :: PrimDarcsOption 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 :: PrimDarcsOption (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 :: PrimDarcsOption 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 :: PrimDarcsOption 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
$c== :: SelectDeps -> SelectDeps -> Bool
== :: SelectDeps -> SelectDeps -> Bool
$c/= :: SelectDeps -> SelectDeps -> Bool
/= :: 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
$cshowsPrec :: Int -> SelectDeps -> ShowS
showsPrec :: Int -> SelectDeps -> ShowS
$cshow :: SelectDeps -> String
show :: SelectDeps -> String
$cshowList :: [SelectDeps] -> ShowS
showList :: [SelectDeps] -> ShowS
Show)

selectDeps :: PrimDarcsOption SelectDeps
selectDeps :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption (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 :: PrimDarcsOption (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 :: PrimDarcsOption (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 :: PrimDarcsOption (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

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

data NotInRemote
  = NotInDefaultRepo
  | NotInRemotePath String

notInRemote :: PrimDarcsOption [NotInRemote]
notInRemote :: PrimDarcsOption [NotInRemote]
notInRemote = (Iso ([Maybe String] -> a) ([NotInRemote] -> a)
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> OptSpec DarcsOptDescr Flag a ([NotInRemote] -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a ([NotInRemote] -> a))
-> (Iso [Maybe String] [NotInRemote]
    -> Iso ([Maybe String] -> a) ([NotInRemote] -> a))
-> Iso [Maybe String] [NotInRemote]
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> OptSpec DarcsOptDescr Flag a ([NotInRemote] -> a)
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)
 -> OptSpec DarcsOptDescr Flag a ([NotInRemote] -> a))
-> OptSpec DarcsOptDescr Flag a ([Maybe String] -> a)
-> OptSpec DarcsOptDescr Flag a ([NotInRemote] -> a)
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
$c== :: RepoCombinator -> RepoCombinator -> Bool
== :: RepoCombinator -> RepoCombinator -> Bool
$c/= :: RepoCombinator -> RepoCombinator -> Bool
/= :: 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
$cshowsPrec :: Int -> RepoCombinator -> ShowS
showsPrec :: Int -> RepoCombinator -> ShowS
$cshow :: RepoCombinator -> String
show :: RepoCombinator -> String
$cshowList :: [RepoCombinator] -> ShowS
showList :: [RepoCombinator] -> ShowS
Show)

repoCombinator :: PrimDarcsOption RepoCombinator
repoCombinator :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption (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 :: PrimDarcsOption 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" ]

withPrefsTemplates :: PrimDarcsOption WithPrefsTemplates
withPrefsTemplates :: PrimDarcsOption WithPrefsTemplates
withPrefsTemplates = WithPrefsTemplates
-> [RawOptSpec Flag WithPrefsTemplates]
-> PrimDarcsOption WithPrefsTemplates
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault WithPrefsTemplates
WithPrefsTemplates
  [ String
-> [String]
-> Flag
-> WithPrefsTemplates
-> String
-> RawOptSpec Flag WithPrefsTemplates
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"with-prefs-templates"] Flag
F.WithPrefsTemplates WithPrefsTemplates
WithPrefsTemplates String
"create template-filled preferences"
  , String
-> [String]
-> Flag
-> WithPrefsTemplates
-> String
-> RawOptSpec Flag WithPrefsTemplates
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-prefs-templates"] Flag
F.NoPrefsTemplates WithPrefsTemplates
NoPrefsTemplates String
"create empty preferences"
  ]

-- * Specifying patch meta-data

patchname :: PrimDarcsOption (Maybe String)
patchname :: PrimDarcsOption (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 :: PrimDarcsOption (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
$c== :: AskLongComment -> AskLongComment -> Bool
== :: AskLongComment -> AskLongComment -> Bool
$c/= :: AskLongComment -> AskLongComment -> Bool
/= :: 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
$cshowsPrec :: Int -> AskLongComment -> ShowS
showsPrec :: Int -> AskLongComment -> ShowS
$cshow :: AskLongComment -> String
show :: AskLongComment -> String
$cshowList :: [AskLongComment] -> ShowS
showList :: [AskLongComment] -> ShowS
Show)

askLongComment :: PrimDarcsOption (Maybe AskLongComment)
askLongComment :: PrimDarcsOption (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 :: PrimDarcsOption 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 :: PrimDarcsOption Logfile
logfile = Iso (Maybe AbsolutePath -> Bool -> a) (Logfile -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe AbsolutePath -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (Logfile -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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 :: PrimDarcsOption (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 :: PrimDarcsOption 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

lookforadds :: PrimDarcsOption LookForAdds
lookforadds :: PrimDarcsOption LookForAdds
lookforadds = LookForAdds -> PrimDarcsOption LookForAdds
maybelookforadds LookForAdds
NoLookForAdds

maybelookforadds :: LookForAdds -> PrimDarcsOption LookForAdds
maybelookforadds :: LookForAdds -> PrimDarcsOption LookForAdds
maybelookforadds 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 [] [String
"dont-look-for-adds",String
"no-look-for-adds"] Flag
F.NoLookForAdds LookForAdds
NoLookForAdds
    String
"don't look for 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 [Char
'l'] [String
"look-for-adds"] Flag
F.LookForAdds LookForAdds
YesLookForAdds
    String
"look for 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
"boring"] Flag
F.Boring LookForAdds
EvenLookForBoring
    String
"look for any file that could be added, even boring files" ]

lookforreplaces :: PrimDarcsOption LookForReplaces
lookforreplaces :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption UseIndex
useIndex = (Iso (Bool -> a) (UseIndex -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (UseIndex -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (UseIndex -> a))
-> (Iso Bool UseIndex -> Iso (Bool -> a) (UseIndex -> a))
-> Iso Bool UseIndex
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (UseIndex -> a)
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 Bool
includeBoring :: PrimDarcsOption Bool
includeBoring = 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
"boring"] Flag
F.Boring Bool
True String
"don't skip boring files"
  , String
-> [String] -> Flag -> Bool -> String -> RawOptSpec Flag Bool
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-boring"] Flag
F.SkipBoring Bool
False String
"skip boring files" ]

allowProblematicFilenames :: DarcsOption a (Bool -> Bool -> a)
allowProblematicFilenames :: forall a. 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)
-> OptSpec DarcsOptDescr Flag 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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
$c== :: WithContext -> WithContext -> Bool
== :: WithContext -> WithContext -> Bool
$c/= :: WithContext -> WithContext -> Bool
/= :: 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
$cshowsPrec :: Int -> WithContext -> ShowS
showsPrec :: Int -> WithContext -> ShowS
$cshow :: WithContext -> String
show :: WithContext -> String
$cshowList :: [WithContext] -> ShowS
showList :: [WithContext] -> ShowS
Show)

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

withContext :: PrimDarcsOption WithContext
withContext :: PrimDarcsOption WithContext
withContext = (Iso (Bool -> a) (WithContext -> a)
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (WithContext -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (WithContext -> a))
-> (Iso Bool WithContext -> Iso (Bool -> a) (WithContext -> a))
-> Iso Bool WithContext
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (WithContext -> a)
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)
 -> OptSpec DarcsOptDescr Flag a (WithContext -> a))
-> OptSpec DarcsOptDescr Flag a (Bool -> a)
-> OptSpec DarcsOptDescr Flag a (WithContext -> a)
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]
diffOptions :: [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
$c== :: ExternalDiff -> ExternalDiff -> Bool
== :: ExternalDiff -> ExternalDiff -> Bool
$c/= :: ExternalDiff -> ExternalDiff -> Bool
/= :: 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
$cshowsPrec :: Int -> ExternalDiff -> ShowS
showsPrec :: Int -> ExternalDiff -> ShowS
$cshow :: ExternalDiff -> String
show :: ExternalDiff -> String
$cshowList :: [ExternalDiff] -> ShowS
showList :: [ExternalDiff] -> ShowS
Show)

extDiff :: PrimDarcsOption ExternalDiff
extDiff :: PrimDarcsOption ExternalDiff
extDiff = Iso (Maybe String -> [String] -> Bool -> a) (ExternalDiff -> a)
-> OptSpec
     DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (ExternalDiff -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (ExternalDiff -> a))
-> OptSpec
     DarcsOptDescr Flag a (Maybe String -> [String] -> Bool -> a)
-> OptSpec DarcsOptDescr Flag a (ExternalDiff -> a)
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 :: PrimDarcsOption (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 :: PrimDarcsOption [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 :: PrimDarcsOption 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" ]

-- * Running 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
$c== :: TestChanges -> TestChanges -> Bool
== :: TestChanges -> TestChanges -> Bool
$c/= :: TestChanges -> TestChanges -> Bool
/= :: TestChanges -> TestChanges -> Bool
Eq)

testChanges :: PrimDarcsOption TestChanges
testChanges :: PrimDarcsOption TestChanges
testChanges = Iso (RunTest -> LeaveTestDir -> a) (TestChanges -> a)
-> OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
-> OptSpec DarcsOptDescr Flag a (TestChanges -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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 {t}. (RunTest -> LeaveTestDir -> t) -> TestChanges -> t
fw (TestChanges -> a) -> RunTest -> LeaveTestDir -> a
forall {t}. (TestChanges -> t) -> RunTest -> LeaveTestDir -> t
bw) (OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
 -> OptSpec DarcsOptDescr Flag a (TestChanges -> a))
-> OptSpec DarcsOptDescr Flag a (RunTest -> LeaveTestDir -> a)
-> OptSpec DarcsOptDescr Flag a (TestChanges -> a)
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 -> t) -> TestChanges -> t
fw RunTest -> LeaveTestDir -> t
k TestChanges
NoTestChanges = RunTest -> LeaveTestDir -> t
k RunTest
NoRunTest LeaveTestDir
NoLeaveTestDir
  fw RunTest -> LeaveTestDir -> t
k (YesTestChanges LeaveTestDir
ltd) = RunTest -> LeaveTestDir -> t
k RunTest
YesRunTest LeaveTestDir
ltd
  bw :: (TestChanges -> t) -> RunTest -> LeaveTestDir -> t
bw TestChanges -> t
k RunTest
NoRunTest LeaveTestDir
_ = TestChanges -> t
k TestChanges
NoTestChanges
  bw TestChanges -> t
k RunTest
YesRunTest LeaveTestDir
ltd = TestChanges -> t
k (LeaveTestDir -> TestChanges
YesTestChanges LeaveTestDir
ltd)

__runTest :: PrimDarcsOption RunTest
__runTest :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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)
-> OptSpec DarcsOptDescr Flag a (HeaderFields -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (HeaderFields -> a))
-> OptSpec
     DarcsOptDescr
     Flag
     a
     ([String]
      -> [String] -> Maybe String -> Maybe String -> Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (HeaderFields -> a)
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 :: PrimDarcsOption (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 :: PrimDarcsOption [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 :: PrimDarcsOption [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 :: PrimDarcsOption (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 :: PrimDarcsOption (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 :: PrimDarcsOption (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

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

sendmailCmd :: PrimDarcsOption (Maybe String)
sendmailCmd :: PrimDarcsOption (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 :: PrimDarcsOption 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 :: PrimDarcsOption (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 :: PrimDarcsOption 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 :: PrimDarcsOption (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
$c== :: Sign -> Sign -> Bool
== :: Sign -> Sign -> Bool
$c/= :: Sign -> Sign -> Bool
/= :: 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
$cshowsPrec :: Int -> Sign -> ShowS
showsPrec :: Int -> Sign -> ShowS
$cshow :: Sign -> String
show :: Sign -> String
$cshowList :: [Sign] -> ShowS
showList :: [Sign] -> ShowS
Show)

sign :: PrimDarcsOption Sign
sign :: PrimDarcsOption 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
$c== :: Verify -> Verify -> Bool
== :: Verify -> Verify -> Bool
$c/= :: Verify -> Verify -> Bool
/= :: 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
$cshowsPrec :: Int -> Verify -> ShowS
showsPrec :: Int -> Verify -> ShowS
$cshow :: Verify -> String
show :: Verify -> String
$cshowList :: [Verify] -> ShowS
showList :: [Verify] -> ShowS
Show)

verify :: PrimDarcsOption Verify
verify :: PrimDarcsOption 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 :: PrimDarcsOption (Maybe AllowConflicts)
conflictsNo = AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts AllowConflicts
NoAllowConflicts

-- | pull, rebase pull: default to 'YesAllowConflicts' 'MarkConflicts'
conflictsYes :: PrimDarcsOption (Maybe AllowConflicts)
conflictsYes :: PrimDarcsOption (Maybe AllowConflicts)
conflictsYes = AllowConflicts -> PrimDarcsOption (Maybe AllowConflicts)
conflicts (ResolveConflicts -> AllowConflicts
YesAllowConflicts ResolveConflicts
MarkConflicts)

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 (ResolveConflicts -> AllowConflicts
YesAllowConflicts ResolveConflicts
MarkConflicts)) 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 (ResolveConflicts -> AllowConflicts
YesAllowConflicts ResolveConflicts
NoResolveConflicts))
      String
"allow conflicts, but don't mark them"
  , String
-> [String]
-> (String -> Flag)
-> (Flag -> [String])
-> (String -> Maybe AllowConflicts)
-> (Maybe AllowConflicts -> [String])
-> String
-> String
-> RawOptSpec Flag (Maybe AllowConflicts)
forall f v.
String
-> [String]
-> (String -> f)
-> (f -> [String])
-> (String -> v)
-> (v -> [String])
-> String
-> String
-> RawOptSpec f v
RawStrArg [] [String
"external-merge"]
    String -> Flag
F.ExternalMerge (\Flag
f -> [String
s | F.ExternalMerge String
s <- [Flag
f]])
    (AllowConflicts -> Maybe AllowConflicts
forall a. a -> Maybe a
Just (AllowConflicts -> Maybe AllowConflicts)
-> (String -> AllowConflicts) -> String -> Maybe AllowConflicts
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ResolveConflicts -> AllowConflicts
YesAllowConflicts (ResolveConflicts -> AllowConflicts)
-> (String -> ResolveConflicts) -> String -> AllowConflicts
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ResolveConflicts
ExternalMerge)
    (\Maybe AllowConflicts
v -> [String
s | Just (YesAllowConflicts (ExternalMerge String
s)) <- [Maybe AllowConflicts
v]])
    String
"COMMAND" String
"use external tool to merge conflicts"
  , 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" ]

-- | pull, apply, rebase pull, rebase apply
reorder :: PrimDarcsOption Reorder
reorder :: PrimDarcsOption 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" ]

-- | push; same as 'reorder' but with help descriptions swapped
reorderPush :: PrimDarcsOption Reorder
reorderPush :: PrimDarcsOption Reorder
reorderPush = 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 remote-only patches on top of local 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 local-only patches on top of remote ones" ]

-- * Optimizations

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

-- | push
compress :: PrimDarcsOption Compression
compress :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: RawDarcsOption
__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 :: RawDarcsOption
__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 :: PrimDarcsOption 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" ]

optimizeDeep :: PrimDarcsOption OptimizeDeep
optimizeDeep :: PrimDarcsOption OptimizeDeep
optimizeDeep = OptimizeDeep
-> [RawOptSpec Flag OptimizeDeep] -> PrimDarcsOption OptimizeDeep
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault OptimizeDeep
OptimizeShallow
  [ String
-> [String]
-> Flag
-> OptimizeDeep
-> String
-> RawOptSpec Flag OptimizeDeep
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"deep"] Flag
F.OptimizeDeep OptimizeDeep
OptimizeDeep
    String
"also optimize clean tags in the complete history"
  , String
-> [String]
-> Flag
-> OptimizeDeep
-> String
-> RawOptSpec Flag OptimizeDeep
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"shallow"] Flag
F.OptimizeShallow OptimizeDeep
OptimizeShallow
    String
"only reorder recent patches (works with lazy repo)" ]

-- * 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
$c== :: Output -> Output -> Bool
== :: Output -> Output -> Bool
$c/= :: Output -> Output -> Bool
/= :: 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
$cshowsPrec :: Int -> Output -> ShowS
showsPrec :: Int -> Output -> ShowS
$cshow :: Output -> String
show :: Output -> String
$cshowList :: [Output] -> ShowS
showList :: [Output] -> ShowS
Show)

output :: PrimDarcsOption (Maybe Output)
output :: PrimDarcsOption (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
$c== :: WithSummary -> WithSummary -> Bool
== :: WithSummary -> WithSummary -> Bool
$c/= :: WithSummary -> WithSummary -> Bool
/= :: 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
$cshowsPrec :: Int -> WithSummary -> ShowS
showsPrec :: Int -> WithSummary -> ShowS
$cshow :: WithSummary -> String
show :: WithSummary -> String
$cshowList :: [WithSummary] -> ShowS
showList :: [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 :: PrimDarcsOption WithSummary
withSummary = (Iso (Maybe WithSummary -> a) (WithSummary -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> OptSpec DarcsOptDescr Flag a (WithSummary -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (WithSummary -> a))
-> (Iso (Maybe WithSummary) WithSummary
    -> Iso (Maybe WithSummary -> a) (WithSummary -> a))
-> Iso (Maybe WithSummary) WithSummary
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> OptSpec DarcsOptDescr Flag a (WithSummary -> a)
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)
 -> OptSpec DarcsOptDescr Flag a (WithSummary -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe WithSummary -> a)
-> OptSpec DarcsOptDescr Flag a (WithSummary -> a)
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" ]

remoteDarcs :: PrimDarcsOption RemoteDarcs
remoteDarcs :: PrimDarcsOption RemoteDarcs
remoteDarcs = Iso (Maybe String -> a) (RemoteDarcs -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (RemoteDarcs -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
forall (f :: * -> *) a b. IsoFunctor f => Iso a b -> f a -> f b
imap (((Maybe String -> a) -> RemoteDarcs -> a)
-> ((RemoteDarcs -> a) -> Maybe String -> a)
-> Iso (Maybe String -> a) (RemoteDarcs -> a)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (Maybe String -> a) -> RemoteDarcs -> a
forall {t}. (Maybe String -> t) -> RemoteDarcs -> t
fw (RemoteDarcs -> a) -> Maybe String -> a
forall {t}. (RemoteDarcs -> t) -> Maybe String -> t
bw)
  (OptSpec DarcsOptDescr Flag a (Maybe String -> a)
 -> OptSpec DarcsOptDescr Flag a (RemoteDarcs -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (RemoteDarcs -> a)
forall a b. (a -> b) -> a -> b
$ 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
    fw :: (Maybe String -> t) -> RemoteDarcs -> t
fw Maybe String -> t
k (RemoteDarcs String
y) = Maybe String -> t
k (String -> Maybe String
forall a. a -> Maybe a
Just String
y)
    fw Maybe String -> t
k RemoteDarcs
DefaultRemoteDarcs = Maybe String -> t
k Maybe String
forall a. Maybe a
Nothing
    bw :: (RemoteDarcs -> t) -> Maybe String -> t
bw RemoteDarcs -> t
k (Just String
y) = RemoteDarcs -> t
k (String -> RemoteDarcs
RemoteDarcs String
y)
    bw RemoteDarcs -> t
k Maybe String
Nothing = RemoteDarcs -> t
k RemoteDarcs
DefaultRemoteDarcs

umask :: PrimDarcsOption UMask
umask :: PrimDarcsOption UMask
umask = (Iso (Maybe String -> a) (UMask -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (UMask -> a)
forall a b.
Iso a b
-> OptSpec DarcsOptDescr Flag a a -> OptSpec DarcsOptDescr Flag a b
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)
 -> OptSpec DarcsOptDescr Flag a (UMask -> a))
-> (Iso (Maybe String) UMask
    -> Iso (Maybe String -> a) (UMask -> a))
-> Iso (Maybe String) UMask
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (UMask -> a)
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)
 -> OptSpec DarcsOptDescr Flag a (UMask -> a))
-> OptSpec DarcsOptDescr Flag a (Maybe String -> a)
-> OptSpec DarcsOptDescr Flag a (UMask -> a)
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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: RawDarcsOption
__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 :: RawDarcsOption
__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 :: PrimDarcsOption 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 AbsolutePath -> Maybe AbsolutePath -> a)
marks :: forall a.
DarcsOption a (Maybe AbsolutePath -> Maybe AbsolutePath -> a)
marks = PrimOptSpec
  DarcsOptDescr Flag (Maybe AbsolutePath -> a) (Maybe AbsolutePath)
PrimDarcsOption (Maybe AbsolutePath)
readMarks PrimOptSpec
  DarcsOptDescr Flag (Maybe AbsolutePath -> a) (Maybe AbsolutePath)
-> OptSpec DarcsOptDescr Flag a (Maybe AbsolutePath -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     (Maybe AbsolutePath -> Maybe AbsolutePath -> 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 AbsolutePath -> a)
PrimDarcsOption (Maybe AbsolutePath)
writeMarks

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

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

-- | Deprecated flag, still present to output an error message.
hashed :: PrimDarcsOption ()
hashed :: PrimDarcsOption ()
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 :: PrimDarcsOption 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 :: PrimDarcsOption (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 :: PrimDarcsOption 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
$c== :: ChangesFormat -> ChangesFormat -> Bool
== :: ChangesFormat -> ChangesFormat -> Bool
$c/= :: ChangesFormat -> ChangesFormat -> Bool
/= :: 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
$cshowsPrec :: Int -> ChangesFormat -> ShowS
showsPrec :: Int -> ChangesFormat -> ShowS
$cshow :: ChangesFormat -> String
show :: ChangesFormat -> String
$cshowList :: [ChangesFormat] -> ShowS
showList :: [ChangesFormat] -> ShowS
Show)

changesFormat :: PrimDarcsOption (Maybe ChangesFormat)
changesFormat :: PrimDarcsOption (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 :: PrimDarcsOption (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 :: PrimDarcsOption 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
$c== :: TestStrategy -> TestStrategy -> Bool
== :: TestStrategy -> TestStrategy -> Bool
$c/= :: TestStrategy -> TestStrategy -> Bool
/= :: 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
$cshowsPrec :: Int -> TestStrategy -> ShowS
showsPrec :: Int -> TestStrategy -> ShowS
$cshow :: TestStrategy -> String
show :: TestStrategy -> String
$cshowList :: [TestStrategy] -> ShowS
showList :: [TestStrategy] -> ShowS
Show)

testStrategy :: PrimDarcsOption TestStrategy
testStrategy :: PrimDarcsOption 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" ]

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

shrinkFailure :: PrimDarcsOption ShrinkFailure
shrinkFailure :: PrimDarcsOption ShrinkFailure
shrinkFailure = ShrinkFailure
-> [RawOptSpec Flag ShrinkFailure] -> PrimDarcsOption ShrinkFailure
forall v. Eq v => v -> [RawOptSpec Flag v] -> PrimDarcsOption v
withDefault ShrinkFailure
ShrinkFailure
  [ String
-> [String]
-> Flag
-> ShrinkFailure
-> String
-> RawOptSpec Flag ShrinkFailure
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"shrink-failure"] Flag
F.ShrinkFailure ShrinkFailure
ShrinkFailure
      String
"try to cut down the set of patches causing a test failure"
  , String
-> [String]
-> Flag
-> ShrinkFailure
-> String
-> RawOptSpec Flag ShrinkFailure
forall f v.
String -> [String] -> f -> v -> String -> RawOptSpec f v
RawNoArg [] [String
"no-shrink-failure"] Flag
F.NoShrinkFailure ShrinkFailure
NoShrinkFailure
      String
"don't try to cut down the set of patches causing a test failure"
  ]

-- ** show files

files :: PrimDarcsOption Bool
files :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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 :: PrimDarcsOption 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
$c== :: GzcrcsAction -> GzcrcsAction -> Bool
== :: GzcrcsAction -> GzcrcsAction -> Bool
$c/= :: GzcrcsAction -> GzcrcsAction -> Bool
/= :: 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
$cshowsPrec :: Int -> GzcrcsAction -> ShowS
showsPrec :: Int -> GzcrcsAction -> ShowS
$cshow :: GzcrcsAction -> String
show :: GzcrcsAction -> String
$cshowList :: [GzcrcsAction] -> ShowS
showList :: [GzcrcsAction] -> ShowS
Show)

gzcrcsActions :: PrimDarcsOption (Maybe GzcrcsAction)
gzcrcsActions :: PrimDarcsOption (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 :: PrimDarcsOption [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 ]