Skip to content

Conversation

@ibrahimoktay
Copy link
Contributor

SortedNames for ArgumentDefinition has been changed.
NameSpecification now uses Array type for elements.

  • Usage will choose the first long name, if available, or otherwise the first short name
  • Help screen will show short names, then long names, in the order of their declaration.

Solves (#167)

Replace this paragraph with a description of your changes and rationale. Provide links to an existing issue or external references/discussions, if appropriate.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Sorting names for option has been changed.
* Usage will choose the first long name, if available, or otherwise the first short name
* Help screen will show short names, then long names, in the order of their declaration.

Solves (#167)
@ibrahimoktay ibrahimoktay changed the title Use the first long name in usage (#167) Use the first long name in usage Jun 4, 2020
Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

Thanks so much for this improvement, @ibrahimoktay! It looks like we need to make sure this is working in a couple edge cases — notes below.

Checkin long names in sort caused single dash long names to be treated as a short name.
Fixed sort to check “short” instead of “long”

Update current test to cover more cases.
*Replace sortedNames with partitionedNames

*Extract uniquifying logic into SequenceExtensions.swift
@ibrahimoktay ibrahimoktay requested a review from natecook1000 June 9, 2020 18:13
Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

Almost there, @ibrahimoktay! Just one note below.

}

var isShort: Bool {
return self == .short(self.valueString.first!)
Copy link
Member

Choose a reason for hiding this comment

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

One last nit — this should use pattern-matching on self instead of an equality comparison. We don't need to be accessing valueString for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. Just changed that.

@natecook1000
Copy link
Member

@swift-ci Please test

@natecook1000 natecook1000 merged commit 59f39ec into apple:master Jun 9, 2020
@ibrahimoktay ibrahimoktay deleted the bugfix branch June 10, 2020 05:35
compnerd added a commit to compnerd/swift-argument-parser that referenced this pull request Jun 11, 2020
Add missing reference to `Utilities/SequenceExtensions.swift` which was failed to be updated with apple#179
@compnerd compnerd mentioned this pull request Jun 11, 2020
4 tasks
natecook1000 pushed a commit that referenced this pull request Jun 12, 2020
Add missing reference to `Utilities/SequenceExtensions.swift` which was failed to be updated with #179
@schlagelk schlagelk mentioned this pull request Jun 29, 2020
4 tasks
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