lib/hyde/cli.rb in hydeweb-0.1.2 vs lib/hyde/cli.rb in hydeweb-0.1.3

- old
+ new

@@ -66,21 +66,42 @@ task.category = :project task(:start) do project - port = (params.extract('-p') || 4833).to_i - host = (params.extract('-o') || '0.0.0.0') + port = (params.extract('-p') || 4833).to_i + host = (params.extract('-o') || '0.0.0.0') + daemon = (!! params.delete('-D')) require 'hyde/server' - Hyde::Server.run! :Host => host, :Port => port + if daemon + pid = fork { Hyde::Server.run! :Host => host, :Port => port, :quiet => true } + sleep 2 + puts + puts "Listening on #{host}:#{port} on pid #{pid}." + puts "To stop: kill #{pid}" + else + Hyde::Server.run! :Host => host, :Port => port + end end task.description = "Starts the server" task.category = :project + task.help = %{ + Usage: + #{executable} start [-p PORT] [-o HOST] [-D] + + Starts an HTTP server so you may rapidly test your project locally. + + If the -p and/or -o is specified, it will listen on the specified HOST:PORT. + Otherwise, the default is 0.0.0.0:4833. + + If -D is specified, it goes into daemon mode. + }.gsub(/^ {4}/, '').strip.split("\n") + task(:version) do puts "Hyde #{Hyde::VERSION}" end task.description = "Shows the current version" @@ -106,12 +127,12 @@ unless project? err err "Get started by typing:" err " $ #{executable} create my_project" - err - err "Type `#{executable} help COMMAND` for additional help on a command." end + err + err "Type `#{executable} help COMMAND` for additional help on a command." end task.description = "Shows help for a given command" task.usage = "help [COMMAND]" task.category = :misc