Skip to content

Conversation

tfausak
Copy link
Owner

@tfausak tfausak commented Jun 24, 2024

Fixes #80.

Previously if you passed the same option twice, Gild would silently ignore the first one and use the second one. For example:

# cabal-gild -i x -i y

That command will use y for input and ignore x.

This PR changes the behavior so that Gild will throw an exception in situations like the above. For example:

# cabal-gild -i x -i y
overriding option --input (before: x, after: y)

@tfausak tfausak marked this pull request as ready for review June 24, 2024 01:57
@tfausak tfausak changed the title Add ability to emit warnings Emit warnings when overriding options Jun 24, 2024
emitWarnings =
let toWarnings o l =
fmap (uncurry . flip $ DuplicateOption.DuplicateOption o)
. reverse
Copy link
Owner Author

Choose a reason for hiding this comment

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

I should refactor this to avoid reverse.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Turns out this is not worth the trouble. Plus usually the list will have one or two elements here.

@tfausak
Copy link
Owner Author

tfausak commented Jun 25, 2024

Note that this is a change in behavior since previously some places that would throw an exception will now merely emit a warning.

@tfausak
Copy link
Owner Author

tfausak commented Jun 26, 2024

I think it would be better to avoid changing any existing behavior and instead only add new warnings. That way this won't have to be a breaking change, and I can focus on improving the CLI later.

@tfausak
Copy link
Owner Author

tfausak commented Jun 30, 2024

I'm now wondering if I should scrap this as well and just throw a warning in this case instead of an error. Not sure why I didn't consider that before.

@tfausak tfausak changed the title Emit warnings when overriding options Throw exception when option is overridden Jun 30, 2024
@tfausak tfausak merged commit 132188f into main Jun 30, 2024
@tfausak tfausak deleted the gh-80-monad-warn branch June 30, 2024 11:49
@tfausak tfausak added the bug Something isn't working label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicated command line arguments are ignored
1 participant