Skip to content

Commit fae015f

Browse files
committed
Add repl to swift-help topics
Most just run `swift repl` here, but also reference the possibility of passing Swift Frontend arguments. rdar://109411493
1 parent 261e7b7 commit fae015f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Sources/swift-help/main.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum HelpTopic: ExpressibleByArgument, CustomStringConvertible {
4747
}
4848

4949
enum Subcommand: String, CaseIterable {
50-
case build, package, run, test
50+
case build, package, run, test, repl
5151

5252
var description: String {
5353
switch self {
@@ -59,6 +59,8 @@ enum Subcommand: String, CaseIterable {
5959
return "Run a program from a package"
6060
case .test:
6161
return "Run package tests"
62+
case .repl:
63+
return "Experiment with Swift code interactively"
6264
}
6365
}
6466
}
@@ -111,12 +113,6 @@ struct SwiftHelp: ParsableCommand {
111113
print(" \(plainBold)swift \(command.rawValue)\(plain)\(padding) \(command.description)")
112114
}
113115

114-
// `repl` not included in `Subcommand`, also print it here.
115-
do {
116-
let padding = String(repeating: " ", count: maxSubcommandNameLength - "repl".count)
117-
print(" \(plainBold)swift repl\(plain)\(padding) Experiment with Swift code interactively")
118-
}
119-
120116
print("\n Use \(plainBold)`swift --version`\(plain) for Swift version information.")
121117
print("\n Use \(plainBold)`swift --help`\(plain) for descriptions of available options and flags.")
122118
print("\n Use \(plainBold)`swift help <subcommand>`\(plain) for more information about a subcommand.")
@@ -131,6 +127,16 @@ struct SwiftHelp: ParsableCommand {
131127
if kind == .interactive {
132128
printIntro()
133129
}
130+
case .subcommand(.repl):
131+
print("""
132+
USAGE: swift repl <options>
133+
134+
The Swift REPL runs code interactively with LLDB.
135+
For most purposes, you can just run `swift repl`.
136+
137+
OPTIONS:
138+
This mode takes optional Swift Frontend arguments: see `swift --help`.
139+
""")
134140
case .subcommand(let subcommand):
135141
// Try to find the subcommand adjacent to the help tool.
136142
// If we didn't find the tool there, let the OS search for it.

0 commit comments

Comments
 (0)