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

Fixup help options for built-in flags #474

Merged
merged 3 commits into from Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions Sources/ArgumentParser/Usage/HelpGenerator.swift
Expand Up @@ -307,7 +307,10 @@ internal extension BidirectionalCollection where Element == ParsableCommand.Type
else { return nil }
return ArgumentDefinition(
kind: .named([.long("version")]),
help: .init(help: "Show the version.", key: InputKey(rawValue: "")),
help: .init(
options: [.isOptional],
help: "Show the version.",
key: InputKey(rawValue: "")),
completion: .default,
update: .nullary({ _, _, _ in })
)
Expand All @@ -318,7 +321,10 @@ internal extension BidirectionalCollection where Element == ParsableCommand.Type
guard !names.isEmpty else { return nil }
return ArgumentDefinition(
kind: .named(names),
help: .init(help: "Show help information.", key: InputKey(rawValue: "")),
help: .init(
options: [.isOptional],
help: "Show help information.",
key: InputKey(rawValue: "")),
completion: .default,
update: .nullary({ _, _, _ in })
)
Expand All @@ -328,6 +334,7 @@ internal extension BidirectionalCollection where Element == ParsableCommand.Type
return ArgumentDefinition(
kind: .named([.long("experimental-dump-help")]),
help: .init(
options: [.isOptional],
help: ArgumentHelp("Dump help information as JSON."),
key: InputKey(rawValue: "")),
completion: .default,
Expand Down
Expand Up @@ -27,9 +27,9 @@ final class CountLinesGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar input-file
.Op Fl -prefix
.Op Fl -verbose Ar verbose
.Fl -help Ar help
.Op Fl -prefix Ar prefix
.Op Fl -verbose
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar input-file
Expand Down Expand Up @@ -68,9 +68,9 @@ final class CountLinesGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar input-file
.Op Fl -prefix
.Op Fl -verbose Ar verbose
.Fl -help Ar help
.Op Fl -prefix Ar prefix
.Op Fl -verbose
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar input-file
Expand Down
Expand Up @@ -26,8 +26,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar subcommand
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -130,8 +130,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar subcommand
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -164,10 +164,10 @@ final class MathGenerateManualTests: XCTestCase {
.Nd "Print the sum of the values."
.Sh SYNOPSIS
.Nm
.Op Fl -hex-output Ar hex-output
.Op Fl -hex-output
.Op Ar values...
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl x , -hex-output
Expand Down Expand Up @@ -200,10 +200,10 @@ final class MathGenerateManualTests: XCTestCase {
.Nd "Print the product of the values."
.Sh SYNOPSIS
.Nm
.Op Fl -hex-output Ar hex-output
.Op Fl -hex-output
.Op Ar values...
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl x , -hex-output
Expand Down Expand Up @@ -237,8 +237,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar subcommand
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -271,10 +271,10 @@ final class MathGenerateManualTests: XCTestCase {
.Nd "Print the average of the values."
.Sh SYNOPSIS
.Nm
.Op Fl -kind
.Op Fl -kind Ar kind
.Op Ar values...
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -kind Ar kind
Expand Down Expand Up @@ -308,8 +308,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Op Ar values...
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar values...
Expand Down Expand Up @@ -343,16 +343,16 @@ final class MathGenerateManualTests: XCTestCase {
.Op Ar one-of-four
.Op Ar custom-arg
.Op Ar values...
.Op Fl -test-success-exit-code Ar test-success-exit-code
.Op Fl -test-failure-exit-code Ar test-failure-exit-code
.Op Fl -test-validation-exit-code Ar test-validation-exit-code
.Op Fl -test-custom-exit-code
.Op Fl -file
.Op Fl -directory
.Op Fl -shell
.Op Fl -custom
.Fl -version Ar version
.Fl -help Ar help
.Op Fl -test-success-exit-code
.Op Fl -test-failure-exit-code
.Op Fl -test-validation-exit-code
.Op Fl -test-custom-exit-code Ar test-custom-exit-code
.Op Fl -file Ar file
.Op Fl -directory Ar directory
.Op Fl -shell Ar shell
.Op Fl -custom Ar custom
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar one-of-four
Expand Down
Expand Up @@ -23,10 +23,10 @@ final class RepeatGenerateManualTests: XCTestCase {
.Nm repeat
.Sh SYNOPSIS
.Nm
.Op Fl -count
.Op Fl -include-counter Ar include-counter
.Op Fl -count Ar count
.Op Fl -include-counter
.Ar phrase
.Fl -help Ar help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -count Ar count
Expand Down Expand Up @@ -63,10 +63,10 @@ final class RepeatGenerateManualTests: XCTestCase {
.Nm repeat
.Sh SYNOPSIS
.Nm
.Op Fl -count
.Op Fl -include-counter Ar include-counter
.Op Fl -count Ar count
.Op Fl -include-counter
.Ar phrase
.Fl -help Ar help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -count Ar count
Expand Down
Expand Up @@ -23,11 +23,11 @@ final class RollDiceGenerateManualTests: XCTestCase {
.Nm roll
.Sh SYNOPSIS
.Nm
.Op Fl -times
.Op Fl -sides
.Op Fl -seed
.Op Fl -verbose Ar verbose
.Fl -help Ar help
.Op Fl -times Ar n
.Op Fl -sides Ar m
.Op Fl -seed Ar seed
.Op Fl -verbose
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -times Ar n
Expand Down Expand Up @@ -68,11 +68,11 @@ final class RollDiceGenerateManualTests: XCTestCase {
.Nm roll
.Sh SYNOPSIS
.Nm
.Op Fl -times
.Op Fl -sides
.Op Fl -seed
.Op Fl -verbose Ar verbose
.Fl -help Ar help
.Op Fl -times Ar n
.Op Fl -sides Ar m
.Op Fl -seed Ar seed
.Op Fl -verbose
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -times Ar n
Expand Down