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

CLI-254: "test" gets parsed as test, quotes die :-( #58

Merged
merged 2 commits into from Oct 17, 2021

Conversation

stoty
Copy link
Contributor

@stoty stoty commented Jan 29, 2021

add a new constructor parameter to DefaultParser that disables quote
processing on option arguments

@coveralls
Copy link

coveralls commented Jan 29, 2021

Coverage Status

Coverage increased (+0.07%) to 96.023% when pulling 93d13ca on stoty:CLI-254 into 6c94af3 on apache:master.

@garydgregory
Copy link
Member

-1: Changing the default behavior is a no go.

@stoty
Copy link
Contributor Author

stoty commented Oct 6, 2021

@garydgregory But this doesn't change the default behaviour.

It is adding a new parameter to a new constructor, that must be explicitly set to false to enable the sane behavior.
You get the old broken behaviour with the old constructors.

@stoty
Copy link
Contributor Author

stoty commented Oct 8, 2021

Rebased and added the Builder to DefaultParser.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

@stoty
Thank you for the updated PR. Please see my comments scattered throughout.

}

/**
* Create a new DefaultParser instance with the specified partial matching and quote
Copy link
Member

Choose a reason for hiding this comment

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

"Create" -> "Creates"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* @since 1.5
*/
public static final class Builder
{
Copy link
Member

Choose a reason for hiding this comment

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

Place { at the end of the previous line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/**
* Sets if balanced leading and trailing double quotes should be stripped from option arguments.
*
* with "stripping of balanced leading and trailing double quotes from option arguments" turned
Copy link
Member

Choose a reason for hiding this comment

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

Odd start for a sentence. Sentences should start with a capitalized word.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewritten

*
* with "stripping of balanced leading and trailing double quotes from option arguments" turned
* on, the outermost balanced double quotes of option arguments values will be removed.
* ie.
Copy link
Member

Choose a reason for hiding this comment

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

Odd formatting where "ie." is a line by itself. Better to spell it out anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewritten.

}

/**
* Constructs an DefaultParser with the values declared by this {@link Builder}.
Copy link
Member

Choose a reason for hiding this comment

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

In general, a build methods "Builds", a contructor "Constructs", so "Constructs" -> "Builds".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewritten.

@Test
public void testLongOptionWithEqualsQuoteHandling() throws Exception
{
assumeTrue(parser instanceof DefaultParser);
Copy link
Member

Choose a reason for hiding this comment

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

Why do all these methods say assumeTrue(parser instanceof DefaultParser);?

If these tests are only for DefaultParser, then put the new tests in the proper subclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@stoty
Copy link
Contributor Author

stoty commented Oct 12, 2021

While working on this, I discovered that quote handlings needs to be a tri-valued parameter.
I've changed the parameter into a Boolean, with null representing the old inconsistent behaviour.
This way backwards compatibility is kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants