From 744738d0fe84640dce6608dc3c86048da9cc089e Mon Sep 17 00:00:00 2001 From: Altherlex Alves Date: Mon, 25 Apr 2016 18:01:02 -0300 Subject: [PATCH 1/5] option to clear all releases from crontab --- bin/whenever | 3 +++ lib/whenever/command_line.rb | 12 +++++++++++- lib/whenever/version.rb | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/whenever b/bin/whenever index 70a5bff6..e4085d9c 100755 --- a/bin/whenever +++ b/bin/whenever @@ -20,6 +20,9 @@ OptionParser.new do |opts| options[:clear] = true options[:identifier] = identifier if identifier end + opts.on('-a', '--clear-all-flags-crontab') do |identifier| + options[:clear_all] = true + end opts.on('-s', '--set [variables]', 'Example: --set \'environment=staging&path=/my/sweet/path\'') do |set| options[:set] = set if set end diff --git a/lib/whenever/command_line.rb b/lib/whenever/command_line.rb index 46dd8a9f..7e3b23fe 100644 --- a/lib/whenever/command_line.rb +++ b/lib/whenever/command_line.rb @@ -18,7 +18,7 @@ def initialize(options={}) exit(1) end - if [@options[:update], @options[:write], @options[:clear]].compact.length > 1 + if [@options[:update], @options[:write], @options[:clear], options[:clear_all]].compact.length > 1 warn("[fail] Can only update, write or clear. Choose one.") exit(1) end @@ -33,6 +33,16 @@ def initialize(options={}) def run if @options[:update] || @options[:clear] write_crontab(updated_crontab) + elsif @options[:clear_all] + # Create a file if doesn't exist + system "crontab -l | sed 's/>/>>/' | crontab - " + # Remove crontab + system "crontab -r" + # Reinitilize + system "crontab -l | sed 's/>/>>/' | crontab - " + + puts '[reset] Success to reboot crontab' + exit(0) elsif @options[:write] write_crontab(whenever_cron) else diff --git a/lib/whenever/version.rb b/lib/whenever/version.rb index 3d458916..9c1fa259 100644 --- a/lib/whenever/version.rb +++ b/lib/whenever/version.rb @@ -1,3 +1,3 @@ module Whenever - VERSION = '0.9.4' + VERSION = '0.9.5' end From a0731a1b7aa82133141a840f9fa8d2462cc336b8 Mon Sep 17 00:00:00 2001 From: Altherlex Alves Date: Wed, 14 Dec 2016 19:22:15 -0200 Subject: [PATCH 2/5] Update command_line.rb --- lib/whenever/command_line.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/whenever/command_line.rb b/lib/whenever/command_line.rb index 7e3b23fe..b41373f1 100644 --- a/lib/whenever/command_line.rb +++ b/lib/whenever/command_line.rb @@ -38,7 +38,7 @@ def run system "crontab -l | sed 's/>/>>/' | crontab - " # Remove crontab system "crontab -r" - # Reinitilize + # Reinitialize system "crontab -l | sed 's/>/>>/' | crontab - " puts '[reset] Success to reboot crontab' From 918a66e219185cc603c2cc35149430e33c500d16 Mon Sep 17 00:00:00 2001 From: Altherlex Alves Date: Thu, 15 Dec 2016 10:24:04 -0200 Subject: [PATCH 3/5] Update version.rb --- lib/whenever/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/whenever/version.rb b/lib/whenever/version.rb index 9c1fa259..3d458916 100644 --- a/lib/whenever/version.rb +++ b/lib/whenever/version.rb @@ -1,3 +1,3 @@ module Whenever - VERSION = '0.9.5' + VERSION = '0.9.4' end From 4912dd816667843db6b4f7f01c701de8e1de48d9 Mon Sep 17 00:00:00 2001 From: Altherlex Alves Date: Thu, 15 Dec 2016 10:29:25 -0200 Subject: [PATCH 4/5] Update command_line.rb --- lib/whenever/command_line.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/whenever/command_line.rb b/lib/whenever/command_line.rb index b41373f1..70ecc468 100644 --- a/lib/whenever/command_line.rb +++ b/lib/whenever/command_line.rb @@ -19,7 +19,7 @@ def initialize(options={}) end if [@options[:update], @options[:write], @options[:clear], options[:clear_all]].compact.length > 1 - warn("[fail] Can only update, write or clear. Choose one.") + warn("[fail] Can only update, write, clear or clear_all. Choose one.") exit(1) end From 6976e1d4a71efec4795f119a321796f431d84457 Mon Sep 17 00:00:00 2001 From: Altherlex Alves Date: Thu, 15 Dec 2016 10:57:32 -0200 Subject: [PATCH 5/5] Update whenever --- bin/whenever | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/whenever b/bin/whenever index e4085d9c..bcb26433 100755 --- a/bin/whenever +++ b/bin/whenever @@ -20,7 +20,7 @@ OptionParser.new do |opts| options[:clear] = true options[:identifier] = identifier if identifier end - opts.on('-a', '--clear-all-flags-crontab') do |identifier| + opts.on('-p', '--purge') do |identifier| options[:clear_all] = true end opts.on('-s', '--set [variables]', 'Example: --set \'environment=staging&path=/my/sweet/path\'') do |set|