Skip to content

Commit d24c52c

Browse files
authored
Improve docs for 'option' and 'reqArg' (#8678)
1 parent 605a3c6 commit d24c52c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Cabal/src/Distribution/Simple/Command.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ type ArgPlaceHolder = String
134134

135135
-- | Create an option taking a single OptDescr.
136136
-- No explicit Name is given for the Option, the name is the first LFlag given.
137+
--
138+
-- Example: @'option' sf lf d get set@
139+
-- * @sf@: Short option name, for example: @[\'d\']@. No hyphen permitted.
140+
-- * @lf@: Long option name, for example: @["debug"]@. No hyphens permitted.
141+
-- * @d@: Description of the option, shown to the user in help messages.
142+
-- * @get@: Get the current value of the flag.
143+
-- * @set@: Set the value of the flag. Gets the current value of the flag as a
144+
-- parameter.
137145
option :: SFlags -> LFlags -> Description -> get -> set -> MkOptDescr get set a
138146
-> OptionField a
139147
option sf lf@(n:_) d get set arg = OptionField n [arg sf lf d get set]
@@ -153,6 +161,15 @@ type MkOptDescr get set a = SFlags -> LFlags -> Description -> get -> set
153161
-> OptDescr a
154162

155163
-- | Create a string-valued command line interface.
164+
-- Usually called in the context of 'option' or 'multiOption'.
165+
--
166+
-- Example: @'reqArg' ad mkflag showflag@
167+
--
168+
-- * @ad@: Placeholder shown to the user, e.g. @"FILES"@ if files are expected
169+
-- parameters.
170+
-- * @mkflag@: How to parse the argument into the option.
171+
-- * @showflag@: If parsing goes wrong, display a useful error message to
172+
-- the user.
156173
reqArg :: Monoid b => ArgPlaceHolder -> ReadE b -> (b -> [String])
157174
-> MkOptDescr (a -> b) (b -> a -> a) a
158175
reqArg ad mkflag showflag sf lf d get set =

0 commit comments

Comments
 (0)