lib/localdev.rb in localdev-0.3.1 vs lib/localdev.rb in localdev-0.3.2

- old
+ new

@@ -18,37 +18,37 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA require 'digest/md5' class Localdev - VERSION = '0.3.1' + VERSION = '0.3.2' def initialize @debug = false @localdev = '/etc/hosts-localdev' @hosts = '/etc/hosts' @start = '#==LOCALDEV==#' @end = '#/==LOCALDEV==#' - if !ARGV.first.nil? && [:on, :off, :add, :remove, :list].include?( ARGV.first.to_sym ) + if !ARGV.first.nil? && [:on, :off, :add, :remove, :clear].include?( ARGV.first.to_sym ) require_sudo ensure_localdev_exists end command = ARGV.shift command = command.to_sym unless command.nil? object = ARGV.shift case command when :"--v", :"--version" info - when :on, :off, :status, :list + when :on, :off, :status, :list, :clear send command when :add, :remove require_sudo object.nil? && exit_error_message("'localdev #{command}' requires you to provide a domain") ensure_localdev_exists send command, object when nil, '--help', '-h' - exit_message "Usage: localdev [on|off|status]\n localdev [add|remove] domain" + exit_message "Usage: localdev [on|off|status|list|clear]\n localdev [add|remove] domain" else exit_error_message "Invalid command" end end @@ -153,9 +153,16 @@ def remove domain update_localdev {|domains| domains = domains.delete domain } enable if :on == get_status puts "Removed '#{domain}'" + status + end + + def clear + update_localdev {|domains| domains.clear() } + enable if :on == get_status + puts "Removed all domains" status end def get_status status = :off