1 % Copyright (C) 2002-2004 David Roundy
3 % This program is free software; you can redistribute it and/or modify
4 % it under the terms of the GNU General Public License as published by
5 % the Free Software Foundation; either version 2, or (at your option)
8 % This program is distributed in the hope that it will be useful,
9 % but WITHOUT ANY WARRANTY; without even the implied warranty of
10 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 % GNU General Public License for more details.
13 % You should have received a copy of the GNU General Public License
14 % along with this program; see the file COPYING. If not, write to
15 % the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 % Boston, MA 02110-1301, USA.
19 module Darcs.Flags ( DarcsFlag( .. ), Compression( .. ), compression, want_external_merge, isInteractive) where
20 import Darcs.Patch.MatchData ( PatchMatch )
21 import Darcs.RepoPath ( AbsolutePath, AbsolutePathOrStd )
25 -- | The 'DarcsFlag' type is a list of all flags that can ever be
26 -- passed to darcs, or to one of its commands.
27 data DarcsFlag = Help | ListOptions | NoTest | Test
28 | HelpOnMatch | OnlyChangesToFiles
29 | LeaveTestDir | NoLeaveTestDir
30 | Timings | Debug | DebugVerbose | DebugHTTP
31 | Verbose | NormalVerbosity | Quiet
32 | Target String | Cc String
33 | Output AbsolutePathOrStd | OutputAutoName AbsolutePath
35 | SendmailCmd String | Author String | PatchName String
36 | OnePatch String | SeveralPatch String
37 | AfterPatch String | UpToPatch String
38 | TagName String | LastN Int | PatchIndexRange Int Int
40 | OneTag String | AfterTag String | UpToTag String
41 | Context AbsolutePath | Count
42 | LogFile AbsolutePath | RmLogFile
43 | DistName String | All
44 | Recursive | NoRecursive | Reorder
45 | RestrictPaths | DontRestrictPaths
46 | AskDeps | NoAskDeps | IgnoreTimes | LookForAdds | NoLookForAdds
47 | AnyOrder | CreatorHash String
48 | Intersection | Union | Complement
49 | Sign | SignAs String | NoSign | SignSSL String
51 | Verify AbsolutePath | VerifySSL AbsolutePath
52 | SSHControlMaster | NoSSHControlMaster
53 | EditDescription | NoEditDescription
55 | EditLongComment | NoEditLongComment | PromptLongComment
56 | AllowConflicts | MarkConflicts | NoAllowConflicts
57 | Boring | AllowCaseOnly | AllowWindowsReserved
58 | DontGrabDeps | DontPromptForDependencies | PromptForDependencies
59 | Compress | NoCompress | UnCompress
60 | WorkDir String | RepoDir String | RemoteRepo String
61 | Reply String | ApplyAs String
62 | MachineReadable | HumanReadable
65 | ExternalMerge String | Summary | NoSummary
67 | CheckPoint | Partial | Complete | Lazy | Ephemeral
68 | FixFilePath AbsolutePath AbsolutePath | DiffFlags String
71 | OnePattern PatchMatch | SeveralPattern PatchMatch
72 | AfterPattern PatchMatch | UpToPattern PatchMatch
73 | NonApply | NonVerify | NonForce
74 | DryRun | SetDefault | NoSetDefault
75 | FancyMoveAdd | NoFancyMoveAdd
76 | Disable | SetScriptsExecutable | DontSetScriptsExecutable
77 | UseHashedInventory | UseOldFashionedInventory
79 | PristinePlain | PristineNone | NoUpdateWorking
80 | Sibling AbsolutePath | Relink | RelinkPristine | NoLinks
81 | Files | NoFiles | Directories | NoDirectories
83 | PosthookCmd String | NoPosthook | AskPosthook | RunPosthook
84 | PrehookCmd String | NoPrehook | AskPrehook | RunPrehook
87 | HTTPPipelining | NoHTTPPipelining
93 data Compression = NoCompression | GzipCompression
94 compression :: [DarcsFlag] -> Compression
95 compression f | NoCompress `elem` f = NoCompression
96 | otherwise = GzipCompression
98 want_external_merge :: [DarcsFlag] -> Maybe String
99 want_external_merge [] = Nothing
100 want_external_merge (ExternalMerge c:_) = Just c
101 want_external_merge (_:fs) = want_external_merge fs
103 isInteractive :: [DarcsFlag] -> Bool
104 isInteractive = isInteractive_ True
106 isInteractive_ def [] = def
107 isInteractive_ _ (Interactive:_) = True
108 isInteractive_ _ (All:_) = False
109 isInteractive_ _ (DryRun:fs) = isInteractive_ False fs
110 isInteractive_ def (_:fs) = isInteractive_ def fs