Skip to content

Conversation

@natecook1000
Copy link
Member

Description

This adds two methods for generating the help screen for a command or subcommand.

Detailed Design

The additions includes two methods, one on ParsableArguments and one on ParsableCommand. The second method has a subcommand parameter, and is called on the root command to generate the help text for a subcommand:

let help = RootCommand.helpMessage(for: Subcommand.self)

The two new methods:

extension ParsableArguments {
    /// Returns the text of the help screen for this type.
    public static func helpMessage(columns: Int? = nil) -> String
}

extension ParsableCommand {
    /// Returns the text of the help screen for the given subcommand of this
    /// command.
    public static func helpMessage(
        for subcommand: ParsableCommand.Type,
        columns: Int? = nil
    ) -> String
}

Documentation Plan

Documentation is included for the new methods, and I've added a section at the end of the guide about customizing help.

Test Plan

I've added tests of these APIs wherever we've previously been testing the help screens.

Source Impact

This is an additive change only.

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 natecook1000 requested a review from kylemacomber May 14, 2020 04:29
@mpapple-swift mpapple-swift self-requested a review May 14, 2020 17:08
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000
Copy link
Member Author

@swift-ci Please test

1 similar comment
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit 44fb59e into master May 14, 2020
@natecook1000 natecook1000 deleted the nate/help_message branch May 14, 2020 17:43
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