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 all 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 @@ -29,7 +29,7 @@ final class CountLinesGenerateManualTests: XCTestCase {
.Ar input-file
.Op Fl -prefix Ar prefix
.Op Fl -verbose
.Fl -help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar input-file
Expand Down Expand Up @@ -71,7 +71,7 @@ final class CountLinesGenerateManualTests: XCTestCase {
.Ar input-file
.Op Fl -prefix Ar prefix
.Op Fl -verbose
.Fl -help
.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
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -131,8 +131,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar subcommand
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -168,8 +168,8 @@ final class MathGenerateManualTests: XCTestCase {
.Nm
.Op Fl -hex-output
.Op Ar values...
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl x , -hex-output
Expand Down Expand Up @@ -205,8 +205,8 @@ final class MathGenerateManualTests: XCTestCase {
.Nm
.Op Fl -hex-output
.Op Ar values...
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl x , -hex-output
Expand Down Expand Up @@ -241,8 +241,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Ar subcommand
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -version
Expand Down Expand Up @@ -278,8 +278,8 @@ final class MathGenerateManualTests: XCTestCase {
.Nm
.Op Fl -kind Ar kind
.Op Ar values...
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -kind Ar kind
Expand Down Expand Up @@ -314,8 +314,8 @@ final class MathGenerateManualTests: XCTestCase {
.Sh SYNOPSIS
.Nm
.Op Ar values...
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar values...
Expand Down Expand Up @@ -358,8 +358,8 @@ final class MathGenerateManualTests: XCTestCase {
.Op Fl -directory Ar directory
.Op Fl -shell Ar shell
.Op Fl -custom Ar custom
.Fl -version
.Fl -help
.Op Fl -version
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Ar one-of-four
Expand Down
Expand Up @@ -26,7 +26,7 @@ final class RepeatGenerateManualTests: XCTestCase {
.Op Fl -count Ar count
.Op Fl -include-counter
.Ar phrase
.Fl -help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -count Ar count
Expand Down Expand Up @@ -67,7 +67,7 @@ final class RepeatGenerateManualTests: XCTestCase {
.Op Fl -count Ar count
.Op Fl -include-counter
.Ar phrase
.Fl -help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -count Ar count
Expand Down
Expand Up @@ -27,7 +27,7 @@ final class RollDiceGenerateManualTests: XCTestCase {
.Op Fl -sides Ar m
.Op Fl -seed Ar seed
.Op Fl -verbose
.Fl -help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -times Ar n
Expand Down Expand Up @@ -73,7 +73,7 @@ final class RollDiceGenerateManualTests: XCTestCase {
.Op Fl -sides Ar m
.Op Fl -seed Ar seed
.Op Fl -verbose
.Fl -help
.Op Fl -help
.Sh DESCRIPTION
.Bl -tag -width 6n
.It Fl -times Ar n
Expand Down