Skip to content

Commit fffd3db

Browse files
committed
Merge pull request #231 from allevato/argparse-deprecations
Use regular property initialization for argument defaults.
1 parent 73e2f4e commit fffd3db

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Sources/swift-format/Subcommands/Format.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension SwiftFormatCommand {
2525
@Flag(
2626
name: .shortAndLong,
2727
help: "Overwrite the current file when formatting.")
28-
var inPlace: Bool
28+
var inPlace: Bool = false
2929

3030
@OptionGroup()
3131
var formatOptions: LintFormatOptions

Sources/swift-format/Subcommands/LegacyMain.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ extension SwiftFormatCommand {
2828
/// If not specified, the tool will be run in format mode.
2929
@Option(
3030
name: .shortAndLong,
31-
default: .format,
3231
help: "The mode to run swift-format in. Either 'format', 'lint', or 'dump-configuration'.")
33-
var mode: ToolMode
32+
var mode: ToolMode = .format
3433

3534
@OptionGroup()
3635
var lintFormatOptions: LintFormatOptions
@@ -41,7 +40,7 @@ extension SwiftFormatCommand {
4140
@Flag(
4241
name: .shortAndLong,
4342
help: "Overwrite the current file when formatting ('format' mode only).")
44-
var inPlace: Bool
43+
var inPlace: Bool = false
4544

4645
mutating func validate() throws {
4746
if inPlace && (mode != .format || lintFormatOptions.paths.isEmpty) {

Sources/swift-format/Subcommands/LintFormatOptions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct LintFormatOptions: ParsableArguments {
3737
@Flag(
3838
name: .shortAndLong,
3939
help: "Recursively run on '.swift' files in any provided directories.")
40-
var recursive: Bool
40+
var recursive: Bool = false
4141

4242
/// Whether unparsable files, due to syntax errors or unrecognized syntax, should be ignored or
4343
/// treated as containing an error. When ignored, unparsable files are output verbatim in format
@@ -47,14 +47,14 @@ struct LintFormatOptions: ParsableArguments {
4747
Ignores unparsable files, disabling all diagnostics and formatting for files that contain \
4848
invalid syntax.
4949
""")
50-
var ignoreUnparsableFiles: Bool
50+
var ignoreUnparsableFiles: Bool = false
5151

5252
/// The list of paths to Swift source files that should be formatted or linted.
5353
@Argument(help: "Zero or more input filenames.")
5454
var paths: [String] = []
5555

56-
@Flag(help: .hidden) var debugDisablePrettyPrint: Bool
57-
@Flag(help: .hidden) var debugDumpTokenStream: Bool
56+
@Flag(help: .hidden) var debugDisablePrettyPrint: Bool = false
57+
@Flag(help: .hidden) var debugDumpTokenStream: Bool = false
5858

5959
mutating func validate() throws {
6060
if recursive && paths.isEmpty {

Sources/swift-format/VersionOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ArgumentParser
1515
/// Encapsulates `--version` flag behavior.
1616
struct VersionOptions: ParsableArguments {
1717
@Flag(name: .shortAndLong, help: "Print the version and exit")
18-
var version: Bool
18+
var version: Bool = false
1919

2020
func validate() throws {
2121
if version {

0 commit comments

Comments
 (0)