Skip to content

cabal-install: Add command 'cabal user-config diff'. - #2159

Merged
23Skidoo merged 1 commit into
haskell:masterfrom
erikd:config
Oct 21, 2014
Merged

23Skidoo merged 1 commit into
haskell:masterfrom
erikd:config

Conversation

@erikd

@erikd erikd commented Oct 11, 2014

Copy link
Copy Markdown
Member

This command prints out a psuedo-diff between the user's ~/.cabal/config file 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.

@erikd

erikd commented Oct 12, 2014

Copy link
Copy Markdown
Member Author

I've figured out a way to test this. Please don't merge until the tests are added.

@erikd

erikd commented Oct 13, 2014

Copy link
Copy Markdown
Member Author

Have a test for this, and then decided to add a saved-config update command and I'm currently working on that.

@erikd

erikd commented Oct 15, 2014

Copy link
Copy Markdown
Member Author

This adds the 'saved-config update' command which required adding de-duplicated lists as discussed in #2160.

@erikd

erikd commented Oct 17, 2014

Copy link
Copy Markdown
Member Author

What needs to happen to make this PR move forward?

@erikd

erikd commented Oct 17, 2014

Copy link
Copy Markdown
Member Author

Discussed this with @dcoutts on IRC. The saved-config as implemented currently does the following:

prompt > dist/build/cabal/cabal help saved-config
Usage: cabal saved-config diff
       cabal saved-config update

 -h --help        Show this help text
 -v --verbose[=n] Control verbosity (n is 0--3, default verbosity level is 1)

You can edit the cabal configuration file to set defaults:
   /home/erikd/.cabal/config

The diff command does for example:

prompt > dist/build/cabal/cabal saved-config diff
+ documentation: True
+ hyperlink-source: True
+ internal: True
+ tests: True

And update does this:

prompt > dist/build/cabal/cabal saved-config update
Renaming /home/erikd/.cabal/config to /home/erikd/.cabal/config.bak.

That last one should have a better message, along the lines of:

Creating backup config at /home/erikd/.cabal/config.bak.
Writing merged config at /home/erikd/.cabal/config.

We also bike-shedded the name of the saved-config command. The problem is config could be too easily mistaken for configure which does something very different. Maybe a better name for it would be user-config.

@cartazio

Copy link
Copy Markdown
Contributor

i've been doing this by hand for ages.

I WANT THIS.
(and if i've been doing this by hand for for ages, how many folks still have 1.16 style configs with their 1.20's and missing out on parallel builds)

erikd added a commit to erikd/cabal that referenced this pull request Oct 19, 2014
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
@erikd

erikd commented Oct 19, 2014

Copy link
Copy Markdown
Member Author

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.

@erikd erikd changed the title cabal-install: Add command 'cabal saved-config diff'. cabal-install: Add command 'cabal user-config diff'. Oct 19, 2014

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/psuedo/pseudo/

@23Skidoo

Copy link
Copy Markdown
Member

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liftM2 instead of let here is just a style thing, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@erikd

erikd commented Oct 20, 2014

Copy link
Copy Markdown
Member Author

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!

@23Skidoo

Copy link
Copy Markdown
Member

Okay, let's merge this. Thanks for your contribution!

23Skidoo added a commit that referenced this pull request Oct 21, 2014
cabal-install: Add command 'cabal user-config diff'.
@23Skidoo
23Skidoo merged commit c1a2724 into haskell:master Oct 21, 2014
@23Skidoo

Copy link
Copy Markdown
Member

@erikd BTW, can you please add a description of what user-config does to the manual?

erikd added a commit to erikd/cabal that referenced this pull request Oct 21, 2014
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
@erikd

erikd commented Oct 21, 2014

Copy link
Copy Markdown
Member Author

Thanks!

Happy to update the manual, but where is it?

@23Skidoo

Copy link
Copy Markdown
Member

@erikd Cabal/doc/{developing,installing}-packages.markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants