Skip to content

Conversation

@griffin-stewie
Copy link
Contributor

  • I've completed this task

This PR fixes #87.

Plan

Simply we can add defaultValueDescription in ExpressibleByArgument protocol

/// A type that can be expressed as a command-line argument.
public protocol ExpressibleByArgument {
  /// Creates a new instance of this type from a command-line-specified
  /// argument.
  init?(argument: String)

  /// Add this ↓
  var defaultValueDescription: String { get }
}

Source Impact

Default behavior is given by default implementation declared in ExpressibleByArgument as Protocol Extensions. Only users who want to customize need to override defaultValueDescription.

Related Forum Thread

How can I change the default value string displayed in Help? - Related Projects / ArgumentParser - Swift Forums

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

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.

One small nit, then this looks good to go!

final class HelpGenerationTests: XCTestCase {
}

extension URL: ExpressibleByArgument {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can you indent with 2 spaces instead of 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I fixed it now.

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.

🚢

@natecook1000 natecook1000 merged commit e371989 into apple:master Mar 22, 2020
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 support for customizing default value string displayed in Help

2 participants