Vapor Console
Adds Laravel-esque console support to Vapor.
Installation
To add VaporConsole
, add the following package to your Package.swift
.
Package.swift
.Package(url: "https://github.com/qutheory/vapor-console.git", majorVersion: 0)
Next you’ll need modify your main.swift
file to start the console instead of starting the server:
main.swift
Remove server startup
print("Visit http://localhost:8080")
let server = Server()
server.run(port: 8080)
Add Console support
import VaporConsole
let console = Console()
console.run()
Add your own commands
let console = Console([
AppTestCommand.self,
AppOtherTestCommand.self
])
Running Vapor Server
In order to run the Vapor Server now, you should invoke the app command with a “serve” argument:
.build/release/VaporApp serve
Using Console
For information on how to use the console, you can just run the app command:
.build/release/VaporApp
Vapor Framework version 0.1.9
Usage:
command [options] [arguments]
Available commands:
list Lists commands
serve Serve the application
Sample Command
import VaporConsole
public class AppTestCommand: Command {
public override var name: String {
return "app:test"
}
public override var help: String? {
return "Describe what this command does."
}
public override var options: [InputOption] {
return [
InputOption("something", mode: .Optional, help: "Describe what this option does.", value: "default value")
]
}
public override func handle() {
self.info("Successfully called \(self.name)")
}
}