Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append option for user-config command #5008

Merged
merged 2 commits into from
Jan 12, 2018
Merged

Conversation

gbaz
Copy link
Collaborator

@gbaz gbaz commented Jan 8, 2018

  • Patches conform to the [coding conventions (https://github.com/haskell/cabal/#conventions).
  • Any changes that could be relevant to users have been recorded in the changelog.

Should resolve #4901

This adds an additional option for user-config, as --append= or -a. This can be used multiple times, each time adding a new line to the delta on user-config files for init update or diff. This lets tools like the platform installer pass in, e.g. msys directories for extra-prog-path and extra-lib-dirs etc.

Tested on some example files, and new-test passes.

@gbaz
Copy link
Collaborator Author

gbaz commented Jan 8, 2018

@randen once this is merged we can update the windows installer to call either cabal init or cabal update with the relevant msys lines (I guess since we don't have an init-or-update it'll need to be a two step process to check for the existence of the file first...)

@gbaz
Copy link
Collaborator Author

gbaz commented Jan 9, 2018

(travis error seems spurious)

@23Skidoo
Copy link
Member

23Skidoo commented Jan 9, 2018

So, if we're updating an already existing config that has an extra-prog-path entry, it will have two such entries. Does cabal-install handle this case correctly?

Copy link
Member

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

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

Looks OK. Is --append hidden from the help output? Or do you think that it should be exposed to users?

@@ -2446,6 +2448,12 @@ userConfigCommand = CommandUI {
"Overwrite the config file if it already exists."
userConfigForce (\v flags -> flags { userConfigForce = v })
trueArg
, option ['a'] ["append"]
Copy link
Member

Choose a reason for hiding this comment

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

I'd call this --append-lines. Note that you'll still be able to say --append=foo, since --append is an unique prefix.

@gbaz
Copy link
Collaborator Author

gbaz commented Jan 9, 2018

So, if we're updating an already existing config that has an extra-prog-path entry, it will have two such entries. Does cabal-install handle this case correctly?

Actually, it won't have two entries. The semantics of update in general will replace the field, not augment it. That said, cabal-install does handle two such lines correctly.

It may be the "right thing" to augment some lines instead of replace them with update semantics, but we'd have to handle this case by case for all config lines, and that seems too broad for this PR.

@gbaz
Copy link
Collaborator Author

gbaz commented Jan 9, 2018

As such it might be clearer to name the setting "augment" and change the doc to read "Additional setting to augment the config file (replacing a previous setting if it existed)." It isn't hidden from the help output -- no reason not to expose this to end users, imho.

If you agree on the name I'll update the PR.

@gbaz gbaz merged commit 0c602fd into master Jan 12, 2018
@23Skidoo 23Skidoo deleted the gb/user-config-append-lines branch January 17, 2018 08:24
@23Skidoo
Copy link
Member

Sorry for not reacting earlier, was travelling for work. I haven't managed to come up with a better name, so let's use "augment".

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.

Add '--with-msys-location=/path/to/msys' to 'cabal user-config init'
2 participants