Skip to content

Add customization point for command usage text #400

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

Merged
merged 7 commits into from
Feb 11, 2022

Conversation

natecook1000
Copy link
Member

@natecook1000 natecook1000 commented Feb 1, 2022

Description

This adds a usage property to CommandConfiguration that lets tool authors customize their command's usage string.

Detailed Design

The CommandConfiguration type now has a usage property that defaults to a nil string. When non-nil, this string is used instead of the auto-generated usage string.

Documentation Plan

Symbol documentation is included, but the Help article should be updated to show this additional API.

Test Plan

Unit tests cover the new feature.

Source Impact

This is an additive change, and requires a new initializer for CommandConfiguration. Since the new property has a default value, most existing source should not be affected. Source that references the old initializer (instead of just calling it) will receive a deprecation warning.

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

@natecook1000
Copy link
Member Author

@swift-ci Please test macOS platform

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 requested a review from rauhul February 8, 2022 18:18
Copy link
Contributor

@rauhul rauhul left a comment

Choose a reason for hiding this comment

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

Looks good to me! When I find some time I really want to refactor the help and usage generator into resultBuilders, I think it would make the string generation easier to follow and we could make swiftUI like modifiers for the indentation options.

@@ -183,7 +183,7 @@ _base() {
fi
case $prev in
--name)

Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit 5540737 into main Feb 11, 2022
@natecook1000 natecook1000 deleted the nate/more_like_yousage branch February 11, 2022 19:41
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.

2 participants