lib/ajimi/client.rb in ajimi-0.1.0 vs lib/ajimi/client.rb in ajimi-0.2.0
- old
+ new
@@ -2,23 +2,24 @@
module Ajimi
class Client < Thor
attr_accessor :checker, :reporter
+ default_command :check
class_option :ajimifile, :default => './Ajimifile', :desc => "Ajimifile path"
class_option :verbose, :type => :boolean, :default => true
def initialize(*args)
super
@config = Ajimi::Config.load(options[:ajimifile])
@config[:verbose] = options[:verbose] unless options[:verbose].nil?
end
- desc "check", "Show differences between the source and the target server"
- option :check_root_path, :type => :string
- option :find_max_depth, :type => :numeric
- option :enable_check_contents, :type => :boolean, :default => false
+ desc "[check]", "(Default subcommand) Show differences between the source and the target server"
+ option :check_root_path, :aliases => "-r", :type => :string
+ option :find_max_depth, :aliases => "-d", :type => :numeric
+ option :enable_check_contents, :aliases => "-c", :type => :boolean, :default => false
option :limit_check_contents, :type => :numeric, :default => 0
def check
@config.merge!( {
find_max_depth: options[:find_max_depth],
enable_check_contents: options[:enable_check_contents],
@@ -27,11 +28,11 @@
@config[:check_root_path] = options[:check_root_path] if options[:check_root_path]
_check
end
desc "dir <path>", "Show differences between the source and the target server in the specified directory"
- option :find_max_depth, :type => :numeric, :default => 1
+ option :find_max_depth, :aliases => "-d", :type => :numeric, :default => 1
option :ignored_pattern, :type => :string
def dir(path)
@config.merge!( {
check_root_path: path,
find_max_depth: options[:find_max_depth],
@@ -51,31 +52,31 @@
} )
@config[:ignored_contents].merge!( { path => Regexp.new(options[:ignored_pattern]) } ) if options[:ignored_pattern]
_check
end
-
+
desc "exec source|target <command>", "Execute an arbitrary command on the source or the target server"
def exec(server, command)
- raise ArgumentError, "server option must be source or target" unless %w(source target).include? server
+ raise ArgumentError, "server option must be source or target" unless %w(source target).include? server
@server = @config[server.to_sym]
puts "Execute command at #{server}_host: #{@server.host}\n"
stdout = @server.command_exec(command)
puts "#{stdout}"
puts "\n"
end
private
-
+
def _check
@checker ||= Checker.new(@config)
result = @checker.check
@reporter ||= Reporter.new(@checker)
@reporter.report
result
end
-
+
end
end