Skip to content

Commit

Permalink
Merge pull request #792 from hanami/migrate-command-server
Browse files Browse the repository at this point in the history
Migrate server command to new CLI
  • Loading branch information
AlfonsoUceda committed Jul 9, 2017
2 parents 93bb05d + 59249ac commit b2c37fb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
40 changes: 2 additions & 38 deletions lib/hanami/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,15 @@ module Hanami
module CommandLine
include Hanami::Cli

class Version
include Hanami::Cli::Command
register "version"
aliases '--version', '-v'

def call
puts "v#{Hanami::VERSION}"
end
end
require "hanami/command_line/server"
require "hanami/command_line/version"
end

# @api private
class OldCommandLine < Thor
# include Thor::Actions
extend CliBase

desc 'server', 'Starts a hanami server'
long_desc <<-EOS
`hanami server` starts a server for the current hanami project.
$ > hanami server
$ > hanami server -p 4500
EOS
method_option :port, aliases: '-p', desc: 'The port to run the server on'
method_option :server, desc: 'Choose a specific Rack::Handler (webrick, thin, etc)'
method_option :rackup, desc: 'A rackup configuration file path to load (config.ru)'
method_option :host, desc: 'The host address to bind to'
method_option :debug, desc: 'Turn on debug output'
method_option :warn, desc: 'Turn on warnings'
method_option :daemonize, desc: 'If true, the server will daemonize itself (fork, detach, etc)'
method_option :pid, desc: 'Path to write a pid file after daemonize'
method_option :environment, desc: 'Path to environment configuration (config/environment.rb)'
method_option :code_reloading, desc: 'Code reloading', type: :boolean, default: true
method_option :help, desc: 'Displays the usage message'
# @api private
def server
if options[:help]
invoke :help, ['server']
else
require 'hanami/commands/server'
Hanami::Commands::Server.new(options).start
end
end

desc 'rackserver', '[private]'
method_option :port, aliases: '-p', desc: 'The port to run the server on, '
method_option :server, desc: 'choose a specific Rack::Handler, e.g. webrick, thin etc'
Expand Down
27 changes: 27 additions & 0 deletions lib/hanami/command_line/server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Hanami
module CommandLine
class Server
include Hanami::Cli::Command

register 'server'

desc 'Starts a hanami server'

option :port, alias: '-p', desc: 'The port to run the server on'
option :server, desc: 'Choose a specific Rack::Handler (webrick, thin, etc)'
option :rackup, desc: 'A rackup configuration file path to load (config.ru)'
option :host, desc: 'The host address to bind to'
option :debug, desc: 'Turn on debug output'
option :warn, desc: 'Turn on warnings'
option :daemonize, desc: 'If true, the server will daemonize itself (fork, detach, etc)'
option :pid, desc: 'Path to write a pid file after daemonize'
option :environment, desc: 'Path to environment configuration (config/environment.rb)'
option :code_reloading, desc: 'Code reloading', type: :boolean, default: true

def call(options)
require 'hanami/commands/server'
Hanami::Commands::Server.new(options).start
end
end
end
end
14 changes: 14 additions & 0 deletions lib/hanami/command_line/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Hanami
module CommandLine
class Version
include Hanami::Cli::Command

register "version"
aliases '--version', '-v'

def call
puts "v#{Hanami::VERSION}"
end
end
end
end

0 comments on commit b2c37fb

Please sign in to comment.