Skip to content

Commit

Permalink
Don't try to build the app when using only the -h or --help flags…
Browse files Browse the repository at this point in the history
… on the `run` command (#344)

* Don't try to build the app when using the `-h` flag on the `run` command

Fixes #341

* Improve legibility by using guard instead of if statement
  • Loading branch information
tkrajacic authored Mar 8, 2021
1 parent 92a23d4 commit 6518e9d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/VaporToolbox/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation

// Generates an Xcode project
struct Run: AnyCommand {
let help = "Runs an app from the console."
let help = "Runs an app from the console.\nEquivalent to `swift run --enable-test-discovery Run`."

func run(using context: inout CommandContext) throws {
var extraArguments: [String] = []
Expand All @@ -14,6 +14,11 @@ struct Run: AnyCommand {
}

func outputHelp(using context: inout CommandContext) {
guard context.input.arguments.count > 1 else {
context.console.output("\(self.help)")
return
}

do {
context.input.arguments.append("--help")
try self.run(using: &context)
Expand Down

0 comments on commit 6518e9d

Please sign in to comment.