2 {-# LANGUAGE DeriveDataTypeable #-}
3 {-# LANGUAGE DeriveGeneric #-}
4 {-# LANGUAGE FlexibleContexts #-}
5 {-# LANGUAGE RankNTypes #-}
7 -----------------------------------------------------------------------------
10 -- Module : Distribution.Simple.Setup.Register
11 -- Copyright : Isaac Jones 2003-2004
15 -- Maintainer : cabal-devel@haskell.org
16 -- Portability : portable
18 -- Definition of the register command-line options.
19 -- See: @Distribution.Simple.Setup@
20 module Distribution
.Simple
.Setup
.Register
23 , defaultRegisterFlags
28 import Distribution
.Compat
.Prelude
hiding (get
)
31 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
32 import Distribution
.Simple
.Compiler
33 import Distribution
.Simple
.Flag
34 import Distribution
.Verbosity
36 import Distribution
.Simple
.Setup
.Common
38 -- ------------------------------------------------------------
42 -- ------------------------------------------------------------
44 -- | Flags to @register@ and @unregister@: (user package, gen-script,
45 -- in-place, verbosity)
46 data RegisterFlags
= RegisterFlags
47 { regPackageDB
:: Flag PackageDB
48 , regGenScript
:: Flag
Bool
49 , regGenPkgConf
:: Flag
(Maybe FilePath)
50 , regInPlace
:: Flag
Bool
51 , regDistPref
:: Flag
FilePath
52 , regPrintId
:: Flag
Bool
53 , regVerbosity
:: Flag Verbosity
54 , -- Same as in 'buildArgs' and 'copyArgs'
56 , regCabalFilePath
:: Flag
FilePath
58 deriving (Show, Generic
, Typeable
)
60 defaultRegisterFlags
:: RegisterFlags
61 defaultRegisterFlags
=
63 { regPackageDB
= NoFlag
64 , regGenScript
= Flag
False
65 , regGenPkgConf
= NoFlag
66 , regInPlace
= Flag
False
67 , regDistPref
= NoFlag
68 , regPrintId
= Flag
False
70 , regCabalFilePath
= mempty
71 , regVerbosity
= Flag normal
74 registerCommand
:: CommandUI RegisterFlags
77 { commandName
= "register"
79 "Register this package with the compiler."
80 , commandDescription
= Nothing
81 , commandNotes
= Nothing
82 , commandUsage
= \pname
->
83 "Usage: " ++ pname
++ " register [FLAGS]\n"
84 , commandDefaultFlags
= defaultRegisterFlags
85 , commandOptions
= \showOrParseArgs
->
86 [ optionVerbosity regVerbosity
(\v flags
-> flags
{regVerbosity
= v
})
89 (\d flags
-> flags
{regDistPref
= d
})
96 (\v flags
-> flags
{regPackageDB
= v
})
101 , "upon registration, register this package in the user's local package database"
104 ( Flag GlobalPackageDB
106 , "(default)upon registration, register this package in the system-wide package database"
113 "register the package in the build location, so it can be used without being installed"
115 (\v flags
-> flags
{regInPlace
= v
})
120 "instead of registering, generate a script to register later"
122 (\v flags
-> flags
{regGenScript
= v
})
127 "instead of registering, generate a package registration file/directory"
129 (\v flags
-> flags
{regGenPkgConf
= v
})
130 (optArg
' "PKG" Flag flagToList
)
134 "print the installed package ID calculated for this package"
136 (\v flags
-> flags
{regPrintId
= v
})
141 unregisterCommand
:: CommandUI RegisterFlags
144 { commandName
= "unregister"
146 "Unregister this package with the compiler."
147 , commandDescription
= Nothing
148 , commandNotes
= Nothing
149 , commandUsage
= \pname
->
150 "Usage: " ++ pname
++ " unregister [FLAGS]\n"
151 , commandDefaultFlags
= defaultRegisterFlags
152 , commandOptions
= \showOrParseArgs
->
153 [ optionVerbosity regVerbosity
(\v flags
-> flags
{regVerbosity
= v
})
156 (\d flags
-> flags
{regDistPref
= d
})
163 (\v flags
-> flags
{regPackageDB
= v
})
168 , "unregister this package in the user's local package database"
171 ( Flag GlobalPackageDB
173 , "(default) unregister this package in the system-wide package database"
180 "Instead of performing the unregister command, generate a script to unregister later"
182 (\v flags
-> flags
{regGenScript
= v
})
187 emptyRegisterFlags
:: RegisterFlags
188 emptyRegisterFlags
= mempty
190 instance Monoid RegisterFlags
where
194 instance Semigroup RegisterFlags
where