Sha256: e3eedae143f093545699197c540c1432c1e40b81ac1621c906a20c2769f41272
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# -*- ruby -*- # frozen_string_literal: true require 'mongrel2/config' require 'mongrel2/cli' unless defined?( Mongrel2::CLI ) # Mongrel2 routes command module Mongrel2::CLI::RoutesCommand extend Mongrel2::CLI::Subcommand desc "Show the routes under a host." arg :SERVERNAME, :optional arg :HOSTNAME, :optional command :routes do |routescmd| routescmd.action do |globals, options, args| servername = args.shift hostname = args.shift # Start with all hosts, then narrow it down if a server and/or host was given. if servername server = Mongrel2::Config::Server[ servername ] or exit_now! "No such server '#{servername}'" hosts = server.hosts_dataset else hosts = Mongrel2::Config::Host.dataset end hosts = hosts.where( name: hostname ) if hostname # Output a section for each host hosts.each do |host| header = "ROUTES for host %s/%s:" % [ hl.key(host.server.name), hl.key(host.name) ] prompt.say( hl.header(header) ) routes_table = TTY::Table.new( header: ['Id', 'Path', 'Target'] ) host.routes.each do |route| routes_table << [ route.id, route.path, route.target ] end prompt.say( routes_table.render(:unicode) ) prompt.say( "\n" ) end end end end # module Mongrel2::CLI::RoutesCommand
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongrel2-0.55.0 | lib/mongrel2/cli/routes.rb |
mongrel2-0.54.0 | lib/mongrel2/cli/routes.rb |