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.Hscolour
14 -- Copyright : Isaac Jones 2003-2004
18 -- Maintainer : cabal-devel@haskell.org
19 -- Portability : portable
21 -- Definition of the hscolour command-line options.
22 -- See: @Distribution.Simple.Setup@
23 module Distribution
.Simple
.Setup
.Hscolour
28 , hscolourCabalFilePath
34 , defaultHscolourFlags
38 import Distribution
.Compat
.Prelude
hiding (get
)
41 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
42 import Distribution
.Simple
.Flag
43 import Distribution
.Simple
.Setup
.Common
44 import Distribution
.Utils
.Path
45 import Distribution
.Verbosity
47 -- ------------------------------------------------------------
51 -- ------------------------------------------------------------
53 data HscolourFlags
= HscolourFlags
54 { hscolourCommonFlags
:: !CommonSetupFlags
55 , hscolourCSS
:: Flag
FilePath
56 , hscolourExecutables
:: Flag
Bool
57 , hscolourTestSuites
:: Flag
Bool
58 , hscolourBenchmarks
:: Flag
Bool
59 , hscolourForeignLibs
:: Flag
Bool
61 deriving (Show, Generic
, Typeable
)
63 pattern HscolourCommonFlags
65 -> Flag
(SymbolicPath Pkg
(Dir Dist
))
66 -> Flag
(SymbolicPath CWD
(Dir Pkg
))
67 -> Flag
(SymbolicPath Pkg File
)
70 pattern HscolourCommonFlags
74 , hscolourCabalFilePath
77 ( hscolourCommonFlags
->
79 { setupVerbosity
= hscolourVerbosity
80 , setupDistPref
= hscolourDistPref
81 , setupWorkingDir
= hscolourWorkingDir
82 , setupCabalFilePath
= hscolourCabalFilePath
83 , setupTargets
= hscolourTargets
87 instance Binary HscolourFlags
88 instance Structured HscolourFlags
90 emptyHscolourFlags
:: HscolourFlags
91 emptyHscolourFlags
= mempty
93 defaultHscolourFlags
:: HscolourFlags
94 defaultHscolourFlags
=
96 { hscolourCommonFlags
= defaultCommonSetupFlags
97 , hscolourCSS
= NoFlag
98 , hscolourExecutables
= Flag
False
99 , hscolourTestSuites
= Flag
False
100 , hscolourBenchmarks
= Flag
False
101 , hscolourForeignLibs
= Flag
False
104 instance Monoid HscolourFlags
where
108 instance Semigroup HscolourFlags
where
111 hscolourCommand
:: CommandUI HscolourFlags
114 { commandName
= "hscolour"
116 "Generate HsColour colourised code, in HTML format."
117 , commandDescription
= Just
(\_
-> "Requires the hscolour program.\n")
118 , commandNotes
= Just
$ \_
->
119 "Deprecated in favour of 'cabal haddock --hyperlink-source'."
120 , commandUsage
= \pname
->
121 "Usage: " ++ pname
++ " hscolour [FLAGS]\n"
122 , commandDefaultFlags
= defaultHscolourFlags
123 , commandOptions
= \showOrParseArgs
->
124 withCommonSetupOptions
126 (\c f
-> f
{hscolourCommonFlags
= c
})
131 "Run hscolour for Executables targets"
133 (\v flags
-> flags
{hscolourExecutables
= v
})
138 "Run hscolour for Test Suite targets"
140 (\v flags
-> flags
{hscolourTestSuites
= v
})
145 "Run hscolour for Benchmark targets"
147 (\v flags
-> flags
{hscolourBenchmarks
= v
})
151 ["foreign-libraries"]
152 "Run hscolour for Foreign Library targets"
154 (\v flags
-> flags
{hscolourForeignLibs
= v
})
159 "Run hscolour for all targets"
162 [ hscolourExecutables f
163 , hscolourTestSuites f
164 , hscolourBenchmarks f
165 , hscolourForeignLibs f
170 { hscolourExecutables
= v
171 , hscolourTestSuites
= v
172 , hscolourBenchmarks
= v
173 , hscolourForeignLibs
= v
180 "Use a cascading style sheet"
182 (\v flags
-> flags
{hscolourCSS
= v
})