Skip to content

Commit 84d63b7

Browse files
committed
Some minor frontend tweaks.
- Switch to `@main` on the top-level command. - Move the function that prints the version information into its own file, so it can be swapped out with something else for custom builds. (It would be nice to automate this similar to what swift-testing is doing with their GitPlugin, but I don't want to steal that code verbatim just yet.) - Make the version string on the main branch "main" instead of an older value that just happened to stick around. In the future, this should always be "main" and it can be updated on the actual release branches (or automated ideally).
1 parent 29b5199 commit 84d63b7

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
func printVersionInformation() {
14+
// TODO: Automate updates to this somehow.
15+
print("main")
16+
}

Sources/swift-format/main.swift renamed to Sources/swift-format/SwiftFormatCommand.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import ArgumentParser
1414

1515
/// Collects the command line options that were passed to `swift-format` and dispatches to the
1616
/// appropriate subcommand.
17+
@main
1718
struct SwiftFormatCommand: ParsableCommand {
1819
static var configuration = CommandConfiguration(
1920
commandName: "swift-format",
@@ -29,5 +30,3 @@ struct SwiftFormatCommand: ParsableCommand {
2930
@OptionGroup()
3031
var versionOptions: VersionOptions
3132
}
32-
33-
SwiftFormatCommand.main()

Sources/swift-format/VersionOptions.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ struct VersionOptions: ParsableArguments {
1919

2020
func validate() throws {
2121
if version {
22-
// TODO: Automate updates to this somehow.
23-
print("508.0.0")
22+
printVersionInformation()
2423
throw ExitCode.success
2524
}
2625
}

0 commit comments

Comments
 (0)