Repository navigation
cabal-install: Add command 'cabal user-config diff'. - #2159
Conversation
|
I've figured out a way to test this. Please don't merge until the tests are added. |
|
Have a test for this, and then decided to add a |
|
This adds the 'saved-config update' command which required adding de-duplicated lists as discussed in #2160. |
|
What needs to happen to make this PR move forward? |
|
Discussed this with @dcoutts on IRC. The The diff command does for example: And update does this: That last one should have a better message, along the lines of: We also bike-shedded the name of the |
|
i've been doing this by hand for ages. I WANT THIS. |
The 'user-config' command allows pseudo-diff-ing and updating of the user's ~/.cabal/config file. The diff is against what cabal would generated if the user config file did not exist and the update command overlays the user's existing settings over the current version of the default settings and writes it back to ~/.cabal/config. Closes: haskell#2159
|
New version of the patch. Command name has changed to 'user-config' which is a little more obvious. Both 'user-config diff' and 'user-config update' supported. |
|
Haven't read the code carefully, but since it's so self-contained, I think it's good to merge (if @dcoutts is okay with adding a new command). |
There was a problem hiding this comment.
liftM2 instead of let here is just a style thing, right?
There was a problem hiding this comment.
The line with liftM2 is equivalent to:
base <- baseSavedConfig
inital <- initialSavedConfig
let testConfig = mappend base initial
Given a pure function a -> b -> r, liftM2 lifts it into the monad so its type is m a -> m b -> m r. The mappend can't be used directly because both baseSavedConfig and initialSavedConfig are I/O actions.
It saves two lines of code and the need to name two intermediate variables.
It could also be done using applicative:
testConfig <- mappend <$> baseSavedConfig <*> initialSavedConfig
but I chose liftM2 because this file was already using liftM but didn't import Control.Applicative.
There was a problem hiding this comment.
Sorry, ignore that comment. I shouldn't have been staring at code that late in the evening.
The 'user-config' command allows pseudo-diff-ing and updating of the user's ~/.cabal/config file. The diff is against what cabal would generated if the user config file did not exist and the update command overlays the user's existing settings over the current version of the default settings and writes it back to ~/.cabal/config. Closes: haskell#2159
|
Updated patch with all changes execpt moving the 'user-config' commands to a separate file (its still a good idea, but should be a separate commit). I think this is ready for a merge and I'd like it to be so I can move on to the next thing. Thanks! |
|
Okay, let's merge this. Thanks for your contribution! |
cabal-install: Add command 'cabal user-config diff'.
|
@erikd BTW, can you please add a description of what |
The 'user-config' command allows pseudo-diff-ing and updating of the user's ~/.cabal/config file. The diff is against what cabal would generated if the user config file did not exist and the update command overlays the user's existing settings over the current version of the default settings and writes it back to ~/.cabal/config. Closes: haskell#2159
|
Thanks! Happy to update the manual, but where is it? |
|
@erikd |
This command prints out a psuedo-diff between the user's
~/.cabal/configfile and what cabal would generate if it did not exist.Tested with ghc 7.8.3 and 7.4.2. I'm trying to write a unit-test for it, but that's a little 'deep'. Thought I'd get some feedback on this first.