lib/miu/command.rb in miu-0.1.0 vs lib/miu/command.rb in miu-0.2.0
- old
+ new
@@ -1,35 +1,42 @@
require 'miu'
+require 'miu/cli_base'
module Miu
class Command
- def self.new(name, plugin, options = {}, &block)
- require 'thor'
- Class.new ::Thor do
- include ::Thor::Actions
- add_runtime_options!
+ def self.new(name, node, options = {}, &block)
+ Class.new Miu::CLIBase do
+ attr_accessor :node
+ @node = node
class << self
def source_root
- Miu.find_root('Gemfile', plugin.called_from)
+ @node.spec.full_gem_path rescue nil
end
def destination_root
Miu.root
end
def banner(task, namespace = nil, subcommand = nil)
super task, namespace, subcommand || options.fetch(:subcommand, true)
end
- def add_miu_pub_options!
- option 'miu-pub-host', :type => :string, :default => '127.0.0.1', :desc => 'miu pub host'
- option 'miu-pub-port', :type => :numeric, :default => Miu.default_sub_port, :desc => 'miu pub port'
+ def add_miu_pub_options(name)
+ option 'pub-host', :type => :string, :default => '127.0.0.1', :desc => 'miu pub host'
+ option 'pub-port', :type => :numeric, :default => Miu.default_sub_port, :desc => 'miu pub port'
+ option 'pub-tag', :type => :string, :default => "miu.input.#{name}.", :desc => 'miu pub tag'
end
- def add_miu_sub_options!
- option 'miu-sub-host', :type => :string, :default => '127.0.0.1', :desc => 'miu sub host'
- option 'miu-sub-port', :type => :numeric, :default => Miu.default_pub_port, :desc => 'miu sub port'
+ def add_miu_sub_options(name)
+ option 'sub-host', :type => :string, :default => '127.0.0.1', :desc => 'miu sub host'
+ option 'sub-port', :type => :numeric, :default => Miu.default_pub_port, :desc => 'miu sub port'
+ option 'sub-tag', :type => :string, :default => "miu.output.#{name}.", :desc => 'miu sub tag'
+ end
+
+ def add_miu_pub_sub_options(name)
+ add_miu_pub_options name
+ add_miu_sub_options name
end
end
namespace name
class_eval &block if block