Repository navigation
cabal new-clean - #5357
cabal new-clean#5357
Conversation
dcoutts
left a comment
There was a problem hiding this comment.
Looks ok, but I think that because we extend the install command, this will give the new-clean command a bazillion flags that are effectively unused and so unnecessary.
Have a look at the project orchestration module and see if we can get ahold of a dist dir layout without needing much more than the GlobalFlags.
| ( removeDirectoryRecursive ) | ||
|
|
||
| cleanCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags) | ||
| cleanCommand = Client.installCommand |
There was a problem hiding this comment.
Why is it derived from the install command? Do we need so many flags?
|
|
||
| let distDir = distDirectory (distDirLayout baseCtx) | ||
|
|
||
| removeDirectoryRecursive distDir |
There was a problem hiding this comment.
Ahh I see, so using the ProjectOrchestration it looks like we need all this info just to establish the dist dir layout. I strongly suspect however that we could construct the dist dir layout from a whole lot less, and then we wouldn't need to take all these various sets of flags, and would not need to derive from the install command UI.
|
@dcoutts I know this was covered in IRC but just for others/posterity, the reason it's like that is to support removing individual targets, which requires knowing most of the build information. |
|
Huh, was |
|
Do we want to keep the wildly argumentative Even dropping the functionality, there are a few things that we can't get around being able to know (unless we want to only support default use): dist dir prefix and project file name. That's not that bad, though. |
|
I like that a lot better, and personally I don't know if the trade-off in complexity is worth it. If it's going to know how to map a target into the information it needs to clean things up, it'll need to know enough to build stuff. |
Made changes in question, no longer uses the complex UI.
|
It is now properly documented, and unless we really want target-specific cleaning enough to add the substantial complexity increase, I believe this just needs squashing and merging. |
|
I agree that granular |
23Skidoo
left a comment
There was a problem hiding this comment.
Code LGTM, but I'd like the documentation to explicitly list the supported flags, especially --save-config.
|
|
||
| ``cabal new-clean [FLAGS]`` cleans up the temporary files and build artifacts | ||
| stored in the ``dist-newstyle`` folder. By default, it removes the entire folder, | ||
| but it can also selectively remove the build artifacts and spare the caches within. |
There was a problem hiding this comment.
I guess this is no longer true? Or does this mean --save-config? In any case, the wording is a bit vague.
There was a problem hiding this comment.
Also please document the distPref and projectFile flags here.
There was a problem hiding this comment.
That does mean --save-config.
Those flags aren't documented for any of the other commands that take them, they're exactly the same as the ones of the same meaning taken by every other new- command so far, just replicated so I don't drag in every flag down to the municipal flag of Kansas City to get the two things I need.
|
|
||
| 2.4.0.0 (current development version) | ||
| * Completed the 'new-clean' command (#5357). By default it removes | ||
| the entire 'dist-newstyle' directory, but can also selectively remove |
There was a problem hiding this comment.
but can also selectively remove only build artifacts.
Seems like this bit also needs updating/rewording.
| cleanProjectFile (\pf flags -> flags {cleanProjectFile = pf}) | ||
| (reqArg "FILE" (succeedReadE Flag) flagToList) | ||
| , option ['s'] ["save-configure"] | ||
| "Save configuration, only remove build artefacts" |
There was a problem hiding this comment.
s/artefacts/artifacts/
| } | ||
|
|
||
| cleanAction :: CleanFlags -> [String] -> GlobalFlags -> IO () | ||
| cleanAction CleanFlags{..} _ _ = do |
There was a problem hiding this comment.
Maybe fail on unexpected arguments, so that, if we want to extend new-clean, we won't be breaking any code mistakenly relying on being able to pass junk on the command line.
There was a problem hiding this comment.
You're right, that's pretty important/basic.
|
Oh, changelog note? Actually I'll go ahead and write one up myself. |
I think it needs some clean-up most likely, but by my understanding of what it's supposed to do, it's at least feature complete.
Please include the following checklist in your PR:
[ci skip]is used to avoid triggering the build bots.Please also shortly describe how you tested your change. Bonus points for added tests!
Fixes #2957