From 48057cb6c8abeaac87d12e3ee19a161374e79d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Thu, 28 Jul 2011 23:59:31 +0200 Subject: [PATCH] New CLI options: watchdir and guardfile thanks to @nestegg! --- CHANGELOG.md | 4 ++++ lib/core_ext/hash_with_indifferent_access.rb | 9 --------- lib/guard.rb | 5 +---- lib/guard/cli.rb | 13 ++++++------- 4 files changed, 11 insertions(+), 20 deletions(-) delete mode 100644 lib/core_ext/hash_with_indifferent_access.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4e18a..a8a702a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ ## Improvements +- New CLI options: ([@nestegg][]) + - `watchdir`/`-w` to specify the directory in which Guard should watch for changes, + - `guardfile`/`-G` to specify an alternate location for the Guardfile to use. - Pull request [#90](https://github.com/guard/guard/pull/90): Refactoring of color handling in the `Guard::UI`. ([@stereobooster][]) ## 0.5.1 - July 2, 2011 @@ -195,6 +198,7 @@ [@koshigoe]: https://github.com/koshigoe [@mcmire]: https://github.com/mcmire [@mislav]: https://github.com/mislav +[@nestegg]: https://github.com/nestegg [@netzpirat]: https://github.com/netzpirat [@nicksieger]: https://github.com/nicksieger [@niklas]: https://github.com/niklas diff --git a/lib/core_ext/hash_with_indifferent_access.rb b/lib/core_ext/hash_with_indifferent_access.rb deleted file mode 100644 index cfb83e7..0000000 --- a/lib/core_ext/hash_with_indifferent_access.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Thor - module CoreExt #:nodoc: - class HashWithIndifferentAccess < ::Hash #:nodoc: - def has_key?(key) - super(convert_key(key)) - end - end - end -end diff --git a/lib/guard.rb b/lib/guard.rb index a9559d9..024ac02 100644 --- a/lib/guard.rb +++ b/lib/guard.rb @@ -1,6 +1,3 @@ -require 'core_ext/hash_with_indifferent_access' -#require 'pry' - module Guard autoload :UI, 'guard/ui' @@ -17,7 +14,7 @@ module Guard # initialize this singleton def setup(options = {}) @options = options - @listener = Listener.select_and_init((options[:watchdir]) ? File.expand_path(options[:watchdir]) : Dir.pwd) + @listener = Listener.select_and_init(@options[:watchdir] ? File.expand_path(@options[:watchdir]) : Dir.pwd) @guards = [] @options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off diff --git a/lib/guard/cli.rb b/lib/guard/cli.rb index 2193558..78e45d9 100644 --- a/lib/guard/cli.rb +++ b/lib/guard/cli.rb @@ -5,13 +5,12 @@ module Guard class CLI < Thor default_task :start - method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell before each change/run_all/reload" - method_option :notify, :type => :boolean, :default => true, :aliases => '-n', :banner => "Notifications feature (growl/libnotify)" - method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages" - method_option :group, :type => :array, :default => [], :aliases => '-g', :banner => "Run only the passed groups" - - method_option :guardfile, :type => :string, :aliases => '-C', :banner => "Specify a Guardfile" - method_option :watchdir, :type => :string, :default => '.', :aliases => '-w', :banner => "Specify the directory to watch" + method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell before each change/run_all/reload" + method_option :notify, :type => :boolean, :default => true, :aliases => '-n', :banner => "Notifications feature (growl/libnotify)" + method_option :debug, :type => :boolean, :default => false, :aliases => '-d', :banner => "Print debug messages" + method_option :group, :type => :array, :default => [], :aliases => '-g', :banner => "Run only the passed groups" + method_option :watchdir, :type => :string, :aliases => '-w', :banner => "Specify the directory to watch" + method_option :guardfile, :type => :string, :aliases => '-G', :banner => "Specify a Guardfile" desc "start", "Starts Guard" def start