lib/maid/app.rb in maid-0.1.4.alpha.2 vs lib/maid/app.rb in maid-0.2.0.alpha.1

- old
+ new

@@ -1,8 +1,7 @@ require 'fileutils' -require 'rubygems' require 'thor' class Maid::App < Thor check_unknown_options! default_task 'help' @@ -10,55 +9,60 @@ def self.sample_rules_path File.join(File.dirname(Maid::Maid::DEFAULTS[:rules_path]), 'rules.sample.rb') end desc 'clean', 'Clean based on rules' - method_option :rules, :type => :string, :aliases => %w[-r] - method_option :noop, :type => :boolean, :aliases => %w[-n --dry-run] - method_option :silent, :type => :boolean, :aliases => %w[-s] + method_option :rules, :type => :string, :aliases => %w(-r) + method_option :noop, :type => :boolean, :aliases => %w(-n --dry-run) + method_option :silent, :type => :boolean, :aliases => %w(-s) def clean maid = Maid::Maid.new(maid_options(options)) if Maid::TrashMigration.needed? migrate_trash return end unless options.silent? || options.noop? - say "Logging actions to #{maid.log_device.inspect}" + say "Logging actions to #{ maid.log_device.inspect }" end maid.load_rules maid.clean end - desc 'version', 'Print version number' + desc 'version', 'Print version information (optionally: system info)' + method_option :long, :type => :boolean, :aliases => %w(-l) def version - say Maid::VERSION + if options.long? + say Maid::UserAgent.value + else + say Maid::VERSION + end end - desc 'sample', "Create sample rules at #{self.sample_rules_path}" + desc 'sample', "Create sample rules at #{ self.sample_rules_path }" def sample path = self.class.sample_rules_path FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w').puts(File.read(File.join(File.dirname(__FILE__), 'rules.sample.rb'))) - say "Sample rules created at #{path.inspect}", :green + say "Sample rules created at #{ path.inspect }", :green end no_tasks do def maid_options(options) h = {} if options['noop'] # You're testing, so a simple log goes to STDOUT and no actions are taken - h[:file_options] = {:noop => true} + h[:file_options] = { :noop => true } unless options['silent'] h[:logger] = false h[:log_device] = STDOUT - h[:log_formatter] = lambda { |_, _, _, msg| "#{msg}\n" } + h[:log_formatter] = lambda { |_, _, _, msg| "#{ msg }\n" } end end if options['rules'] h[:rules_path] = options['rules']