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

feat: print warnings and allow error to be raised when unknown option is used #147

Merged
merged 3 commits into from Oct 13, 2023

Conversation

bethesque
Copy link
Member

PACT-1370

@bethesque bethesque requested a review from YOU54F October 13, 2023 09:05
@bethesque
Copy link
Member Author

Old behaviour with unknown option --foo

Screenshot 2023-10-13 at 8 11 34 pm

New behaviour with unknown option --foo

Screenshot 2023-10-13 at 8 09 49 pm

New behaviour with unknown option --foo and PACT_BROKER_ERROR_ON_UNKNOWN_OPTION=true

Screenshot 2023-10-13 at 8 10 22 pm


From version 1.73.0, warnings will be printed for unknown options, and if the environment variable `PACT_BROKER_ERROR_ON_UNKNOWN_OPTION=true` is set, an error will be raised when an unknown option is used.

In the next major version, an error will be raised by default.
Copy link
Member

Choose a reason for hiding this comment

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

nice

stderr_lines = stderr.readlines
end

expect(stderr_lines.join("\n")).to include(unknown_switches_text)
Copy link
Member

Choose a reason for hiding this comment

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

it's a shame it says unknown switches rather than unknown Option but this is still a much better experience

Usage:
pact-broker publish PACT_DIRS_OR_FILES ... -a, --consumer-app-version=CONSUMER_APP_VERSION -b, --broker-base-url=BROKER_BASE_URL

Options:
-a, --consumer-app-version=CONSUMER_APP_VERSIO

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the terminology used inside the gem is very inconsistent. The words argument, option and switch are all used to mean the same thing in various places. I guess it's what happens when you have multiple people working on a project and you don't have a Terminology Dictator in control.

@YOU54F YOU54F merged commit ceed532 into master Oct 13, 2023
29 checks passed
@YOU54F YOU54F linked an issue Oct 13, 2023 that may be closed by this pull request
@bethesque bethesque deleted the feat/error-on-unknown-option branch October 14, 2023 03:04
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.

Update Thor usage error when there are unknown options specified
2 participants