Skip to content

Commit 8c8ec5a

Browse files
committed
add v1-clean
1 parent 6ab7b31 commit 8c8ec5a

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

cabal-install/Distribution/Client/CmdLegacy.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ instance HasVerbosity Client.ExecFlags where
6969
instance HasVerbosity Client.UpdateFlags where
7070
verbosity = verbosity . Client.updateVerbosity
7171

72+
instance HasVerbosity Setup.CleanFlags where
73+
verbosity = verbosity . Setup.cleanVerbosity
74+
7275
--
7376

7477
legacyCmd :: (HasVerbosity flags) => CommandUI flags -> (flags -> [String] -> globals -> IO action) -> [CommandSpec (globals -> IO action)]

cabal-install/Distribution/Client/Setup.hs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module Distribution.Client.Setup
5050
, userConfigCommand, UserConfigFlags(..)
5151
, manpageCommand
5252
, haddockCommand
53+
, cleanCommand
5354

5455
, parsePackageArgs
5556
--TODO: stop exporting these:
@@ -92,6 +93,7 @@ import Distribution.Simple.Setup
9293
( ConfigFlags(..), BuildFlags(..), ReplFlags
9394
, TestFlags(..), BenchmarkFlags(..)
9495
, SDistFlags(..), HaddockFlags(..)
96+
, CleanFlags(..)
9597
, readPackageDbList, showPackageDbList
9698
, Flag(..), toFlag, flagToMaybe, flagToList, maybeToFlag
9799
, BooleanFlag(..), optionVerbosity
@@ -194,6 +196,7 @@ globalCommand commands = CommandUI {
194196
, "new-exec"
195197
, "new-update"
196198
, "new-install"
199+
, "new-clean"
197200
, "v1-build"
198201
, "v1-configure"
199202
, "v1-repl"
@@ -205,6 +208,7 @@ globalCommand commands = CommandUI {
205208
, "v1-exec"
206209
, "v1-update"
207210
, "v1-install"
211+
, "v1-clean"
208212
]
209213
maxlen = maximum $ [length name | (name, _) <- cmdDescs]
210214
align str = str ++ replicate (maxlen - length str) ' '
@@ -275,6 +279,7 @@ globalCommand commands = CommandUI {
275279
, addCmd "new-exec"
276280
, addCmd "new-update"
277281
, addCmd "new-install"
282+
, addCmd "new-clean"
278283
, par
279284
, startGroup "legacy command aliases"
280285
, addCmd "v1-build"
@@ -288,6 +293,7 @@ globalCommand commands = CommandUI {
288293
, addCmd "v1-exec"
289294
, addCmd "v1-update"
290295
, addCmd "v1-install"
296+
, addCmd "v1-clean"
291297
] ++ if null otherCmds then [] else par
292298
:startGroup "other"
293299
:[addCmd n | n <- otherCmds])
@@ -403,7 +409,7 @@ globalCommand commands = CommandUI {
403409

404410
configureCommand :: CommandUI ConfigFlags
405411
configureCommand = c
406-
{ commandName = "v1-configure"
412+
{ commandName = "configure"
407413
, commandDefaultFlags = mempty
408414
, commandDescription = Just $ \_ -> wrapText $
409415
"Configure how the package is built by setting "
@@ -1221,16 +1227,11 @@ upgradeCommand = configureCommand {
12211227
commandOptions = commandOptions installCommand
12221228
}
12231229

1224-
{-
1225-
cleanCommand :: CommandUI ()
1226-
cleanCommand = makeCommand name shortDesc longDesc emptyFlags options
1227-
where
1228-
name = "clean"
1229-
shortDesc = "Removes downloaded files"
1230-
longDesc = Nothing
1231-
emptyFlags = ()
1232-
options _ = []
1233-
-}
1230+
cleanCommand :: CommandUI CleanFlags
1231+
cleanCommand = Cabal.cleanCommand
1232+
{ commandUsage = \pname ->
1233+
"Usage: " ++ pname ++ " v1-clean [FLAGS]\n"
1234+
}
12341235

12351236
checkCommand :: CommandUI (Flag Verbosity)
12361237
checkCommand = CommandUI {
@@ -1753,8 +1754,7 @@ installCommand = CommandUI {
17531754

17541755
haddockCommand :: CommandUI HaddockFlags
17551756
haddockCommand = Cabal.haddockCommand
1756-
{ commandName = "v1-haddock"
1757-
, commandUsage = usageAlternatives "v1-haddock" $
1757+
{ commandUsage = usageAlternatives "v1-haddock" $
17581758
[ "[FLAGS]", "COMPONENTS [FLAGS]" ]
17591759
}
17601760

cabal-install/main/Main.hs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import Distribution.Client.Setup
4848
, reportCommand
4949
, manpageCommand
5050
, haddockCommand
51+
, cleanCommand
5152
)
5253
import Distribution.Simple.Setup
5354
( HaddockTarget(..)
@@ -57,7 +58,7 @@ import Distribution.Simple.Setup
5758
, ReplFlags(..)
5859
, CopyFlags(..), copyCommand
5960
, RegisterFlags(..), registerCommand
60-
, CleanFlags(..), cleanCommand
61+
, CleanFlags(..)
6162
, TestFlags(..), BenchmarkFlags(..)
6263
, Flag(..), fromFlag, fromFlagOrDefault, flagToMaybe, toFlag
6364
, configAbsolutePaths
@@ -292,7 +293,6 @@ mainWorker args = topHandler $
292293
, regularCmd sandboxCommand sandboxAction
293294
, regularCmd doctestCommand doctestAction
294295
, regularCmd userConfigCommand userConfigAction
295-
, regularCmd cleanCommand cleanAction
296296
, regularCmd genBoundsCommand genBoundsAction
297297
, regularCmd outdatedCommand outdatedAction
298298
, wrapperCmd copyCommand copyVerbosity copyDistPref
@@ -316,6 +316,20 @@ mainWorker args = topHandler $
316316
, regularCmd CmdTest.testCommand CmdTest.testAction
317317
, regularCmd CmdBench.benchCommand CmdBench.benchAction
318318
, regularCmd CmdExec.execCommand CmdExec.execAction
319+
, regularCmd CmdClean.cleanCommand CmdClean.cleanAction
320+
] ++ concat
321+
[ legacyCmd configureExCommand configureAction
322+
, legacyCmd updateCommand updateAction
323+
, legacyCmd buildCommand buildAction
324+
, legacyCmd replCommand replAction
325+
, legacyCmd freezeCommand freezeAction
326+
, legacyCmd haddockCommand haddockAction
327+
, legacyCmd installCommand installAction
328+
, legacyCmd runCommand runAction
329+
, legacyCmd testCommand testAction
330+
, legacyCmd benchmarkCommand benchmarkAction
331+
, legacyCmd execCommand execAction
332+
, legacyCmd cleanCommand cleanAction
319333
]
320334

321335
type Action = GlobalFlags -> IO ()

0 commit comments

Comments
 (0)