First commit to cloned copy of noprocrast 1.6
bin/noprocrast - Cleaned up error messages - Print error when giving invalid or too many inputs lib/noprocrast.rb - Added entries with "www." prefix for hosts without it already specified
This commit is contained in:
parent
f28ac5100d
commit
da532a6b64
|
@ -2,6 +2,15 @@
|
||||||
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocrast')
|
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocrast')
|
||||||
|
|
||||||
|
acceptable = "[on|off|status|edit]"
|
||||||
|
message = "Usage: [sudo] noprocrast #{acceptable}"
|
||||||
|
|
||||||
|
# Bail immediately if inputs are wrong
|
||||||
|
if ARGV.length > 1 then
|
||||||
|
puts message
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case ARGV.first
|
case ARGV.first
|
||||||
when 'on', 'reload'
|
when 'on', 'reload'
|
||||||
|
@ -22,7 +31,9 @@ begin
|
||||||
puts "Saved. Now: noprocrast on"
|
puts "Saved. Now: noprocrast on"
|
||||||
end
|
end
|
||||||
when 'help', '-h', '--help', nil
|
when 'help', '-h', '--help', nil
|
||||||
puts "Usage: [sudo] noprocrast [on|off|status|edit]"
|
puts message
|
||||||
|
else
|
||||||
|
puts "Error: bad input.\n#{message}"
|
||||||
end
|
end
|
||||||
rescue Errno::EACCES
|
rescue Errno::EACCES
|
||||||
puts "Permission denied: try sudo noprocrast"
|
puts "Permission denied: try sudo noprocrast"
|
||||||
|
|
|
@ -12,7 +12,9 @@ class Noprocrast
|
||||||
|
|
||||||
def current_hosts
|
def current_hosts
|
||||||
setup_deny_file_if_required!
|
setup_deny_file_if_required!
|
||||||
File.read(deny_file_path).split(/\n/).select { |line| line.match(/[a-zA-Z0-9]/) }.map(&:strip)
|
hosts = File.read(deny_file_path).split(/\n/).select { |line| line.match(/[a-zA-Z0-9]/) }.map(&:strip)
|
||||||
|
wwwhosts = hosts.map { |h| "www." + h.to_s unless h =~ /^www/ }
|
||||||
|
(hosts + wwwhosts).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def hosts_file_content
|
def hosts_file_content
|
||||||
|
|
Loading…
Reference in New Issue