lib/miu/cli.rb in miu-0.0.6 vs lib/miu/cli.rb in miu-0.1.0
- old
+ new
@@ -41,24 +41,35 @@
print_table table, :indent => 2, :truncate => true
say
end
desc 'start', 'Start miu'
- option 'pub-host', :type => :string, :default => '127.0.0.1', :desc => 'pub host address'
- option 'pub-port', :type => :numeric, :default => Miu.default_pub_port, :desc => 'pub listen port'
- option 'sub-host', :type => :string, :default => '127.0.0.1', :desc => 'sub host address'
- option 'sub-port', :type => :numeric, :default => Miu.default_sub_port, :desc => 'sub listen port'
+ option 'pub-host', :type => :string, :default => '127.0.0.1', :desc => 'pub host'
+ option 'pub-port', :type => :numeric, :default => Miu.default_pub_port, :desc => 'pub port'
+ option 'sub-host', :type => :string, :default => '127.0.0.1', :desc => 'sub host'
+ option 'sub-port', :type => :numeric, :default => Miu.default_sub_port, :desc => 'sub port'
+ option 'verbose', :type => :boolean, :default => false, :desc => 'verbose output', :aliases => '-V'
def start
- opts = options.dup
- opts.keys.each { |k| opts[k.gsub('-', '_')] = opts.delete(k) if k.is_a?(::String) }
- server = Miu::Server.new opts
+ server = Miu::Server.new Miu::Utility.optionalize_keys(options)
server.run
end
+ desc 'cat tag [body]', 'Nyan'
+ option 'host', :type => :string, :default => '127.0.0.1', :desc => 'miu sub host'
+ option 'port', :type => :numeric, :default => Miu.default_sub_port, :desc => 'miu sub port'
+ def cat(tag, body = nil)
+ require 'json'
+ publisher = Miu::Publisher.new :host => options[:host], :port => options[:port]
+ publisher.connect
+ body = JSON.load(body) rescue body
+ publisher.send tag, body
+ end
+
desc 'supervise', 'Supervise miu and plugins'
- def supervise
+ def supervise(*args)
require 'god'
- run "bundle exec god -c #{Miu.default_god_config}"
+ args.unshift "bundle exec god -c #{Miu.default_god_config}"
+ run args.join(' ')
end
desc 'god', 'Miu is a god'
def god(*args)
require 'god'