Skip to content

Add repl to swift-help topics #1382

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Sources/swift-help/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum HelpTopic: ExpressibleByArgument, CustomStringConvertible {
}

enum Subcommand: String, CaseIterable {
case build, package, run, test
case build, package, run, test, repl

var description: String {
switch self {
Expand All @@ -59,6 +59,8 @@ enum Subcommand: String, CaseIterable {
return "Run a program from a package"
case .test:
return "Run package tests"
case .repl:
return "Experiment with Swift code interactively"
}
}
}
Expand Down Expand Up @@ -111,12 +113,6 @@ struct SwiftHelp: ParsableCommand {
print(" \(plainBold)swift \(command.rawValue)\(plain)\(padding) \(command.description)")
}

// `repl` not included in `Subcommand`, also print it here.
do {
let padding = String(repeating: " ", count: maxSubcommandNameLength - "repl".count)
print(" \(plainBold)swift repl\(plain)\(padding) Experiment with Swift code interactively")
}

print("\n Use \(plainBold)`swift --version`\(plain) for Swift version information.")
print("\n Use \(plainBold)`swift --help`\(plain) for descriptions of available options and flags.")
print("\n Use \(plainBold)`swift help <subcommand>`\(plain) for more information about a subcommand.")
Expand All @@ -131,6 +127,16 @@ struct SwiftHelp: ParsableCommand {
if kind == .interactive {
printIntro()
}
case .subcommand(.repl):
print("""
USAGE: swift repl <options>

The Swift REPL runs code interactively with LLDB.
For most purposes, you can just run `swift repl`.

OPTIONS:
This mode takes optional Swift Frontend arguments: see `swift --help`.
""")
case .subcommand(let subcommand):
// Try to find the subcommand adjacent to the help tool.
// If we didn't find the tool there, let the OS search for it.
Expand Down