Skip to content

Commit

Permalink
Merge pull request #34 from vapor/fallback-temp
Browse files Browse the repository at this point in the history
hot patch group fallback capabilities
  • Loading branch information
loganwright authored Apr 19, 2017
2 parents 6642472 + 0375618 commit d673851
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Console/Command/Group.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ public class Group: Runnable {
public var id: String
public var commands: [Runnable]
public var help: [String]
public var fallback: Command?

public init(id: String, commands: [Runnable], help: [String]) {
public init(id: String, commands: [Runnable], help: [String], fallback: Command? = nil) {
self.id = id
self.commands = commands
self.help = help
self.fallback = fallback
}
}
3 changes: 3 additions & 0 deletions Sources/Console/Console/Console+Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ extension ConsoleProtocol {
// group help was requested
printHelp(executable: executable, group: group)
throw ConsoleError.help
} else if let fallback = group.fallback {
foundCommand = fallback
break
} else {
// cannot run groups
throw ConsoleError.noCommand
Expand Down

0 comments on commit d673851

Please sign in to comment.