2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE DeriveDataTypeable #-}
4 {-# LANGUAGE DeriveGeneric #-}
5 {-# LANGUAGE FlexibleContexts #-}
6 {-# LANGUAGE PatternSynonyms #-}
7 {-# LANGUAGE RankNTypes #-}
8 {-# LANGUAGE ViewPatterns #-}
10 -----------------------------------------------------------------------------
13 -- Module : Distribution.Simple.Setup.Register
14 -- Copyright : Isaac Jones 2003-2004
18 -- Maintainer : cabal-devel@haskell.org
19 -- Portability : portable
21 -- Definition of the register command-line options.
22 -- See: @Distribution.Simple.Setup@
23 module Distribution
.Simple
.Setup
.Register
28 , registerCabalFilePath
34 , defaultRegisterFlags
39 import Distribution
.Compat
.Prelude
hiding (get
)
42 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
43 import Distribution
.Simple
.Compiler
44 import Distribution
.Simple
.Flag
45 import Distribution
.Simple
.Setup
.Common
46 import Distribution
.Utils
.Path
47 import Distribution
.Verbosity
49 -- ------------------------------------------------------------
53 -- ------------------------------------------------------------
55 -- | Flags to @register@ and @unregister@: (user package, gen-script,
56 -- in-place, verbosity)
57 data RegisterFlags
= RegisterFlags
58 { registerCommonFlags
:: !CommonSetupFlags
59 , regPackageDB
:: Flag PackageDB
60 , regGenScript
:: Flag
Bool
61 , regGenPkgConf
:: Flag
(Maybe (SymbolicPath Pkg
(Dir PkgConf
)))
62 , regInPlace
:: Flag
Bool
63 , regPrintId
:: Flag
Bool
65 deriving (Show, Generic
, Typeable
)
67 pattern RegisterCommonFlags
69 -> Flag
(SymbolicPath Pkg
(Dir Dist
))
70 -> Flag
(SymbolicPath CWD
(Dir Pkg
))
71 -> Flag
(SymbolicPath Pkg File
)
74 pattern RegisterCommonFlags
78 , registerCabalFilePath
81 ( registerCommonFlags
->
83 { setupVerbosity
= registerVerbosity
84 , setupDistPref
= registerDistPref
85 , setupWorkingDir
= registerWorkingDir
86 , setupCabalFilePath
= registerCabalFilePath
87 , setupTargets
= registerTargets
91 defaultRegisterFlags
:: RegisterFlags
92 defaultRegisterFlags
=
94 { registerCommonFlags
= defaultCommonSetupFlags
95 , regPackageDB
= NoFlag
96 , regGenScript
= Flag
False
97 , regGenPkgConf
= NoFlag
98 , regInPlace
= Flag
False
99 , regPrintId
= Flag
False
102 registerCommand
:: CommandUI RegisterFlags
105 { commandName
= "register"
107 "Register this package with the compiler."
108 , commandDescription
= Nothing
109 , commandNotes
= Nothing
110 , commandUsage
= \pname
->
111 "Usage: " ++ pname
++ " register [FLAGS]\n"
112 , commandDefaultFlags
= defaultRegisterFlags
113 , commandOptions
= \showOrParseArgs
->
114 withCommonSetupOptions
116 (\c f
-> f
{registerCommonFlags
= c
})
123 (\v flags
-> flags
{regPackageDB
= v
})
128 , "upon registration, register this package in the user's local package database"
131 ( Flag GlobalPackageDB
133 , "(default)upon registration, register this package in the system-wide package database"
140 "register the package in the build location, so it can be used without being installed"
142 (\v flags
-> flags
{regInPlace
= v
})
147 "instead of registering, generate a script to register later"
149 (\v flags
-> flags
{regGenScript
= v
})
154 "instead of registering, generate a package registration file/directory"
156 (\v flags
-> flags
{regGenPkgConf
= v
})
157 (optArg
' "PKG" (Flag
. fmap makeSymbolicPath
) (flagToList
. fmap (fmap getSymbolicPath
)))
161 "print the installed package ID calculated for this package"
163 (\v flags
-> flags
{regPrintId
= v
})
168 unregisterCommand
:: CommandUI RegisterFlags
171 { commandName
= "unregister"
173 "Unregister this package with the compiler."
174 , commandDescription
= Nothing
175 , commandNotes
= Nothing
176 , commandUsage
= \pname
->
177 "Usage: " ++ pname
++ " unregister [FLAGS]\n"
178 , commandDefaultFlags
= defaultRegisterFlags
179 , commandOptions
= \showOrParseArgs
->
180 withCommonSetupOptions
182 (\c f
-> f
{registerCommonFlags
= c
})
189 (\v flags
-> flags
{regPackageDB
= v
})
194 , "unregister this package in the user's local package database"
197 ( Flag GlobalPackageDB
199 , "(default) unregister this package in the system-wide package database"
206 "Instead of performing the unregister command, generate a script to unregister later"
208 (\v flags
-> flags
{regGenScript
= v
})
213 emptyRegisterFlags
:: RegisterFlags
214 emptyRegisterFlags
= mempty
216 instance Monoid RegisterFlags
where
220 instance Semigroup RegisterFlags
where