[ditz-talk] [PATCH] Exit cleanly when interrupting config creation, init or reconfigure

Daniel Kalør daniel at kalor.dk
Wed Nov 5 03:30:29 EST 2008


---
 bin/ditz |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/bin/ditz b/bin/ditz
index 886a8fd..2a37dc5 100755
--- a/bin/ditz
+++ b/bin/ditz
@@ -108,7 +108,12 @@ rescue SystemCallError => e
 I wasn't able to find a configuration file #{$opts[:config_file]}.
 We'll set it up right now.
 EOS
-    Ditz::Config.create_interactively.save! $opts[:config_file]
+    begin
+      Ditz::Config.create_interactively.save! $opts[:config_file]
+    rescue Interrupt
+      puts
+      exit 1
+    end
   end
 end
 
@@ -126,12 +131,23 @@ when "init"
   die "#{issue_dir} directory already exists" if issue_dir.exist?
   issue_dir.mkdir
   fn = issue_dir + Ditz::FileStorage::PROJECT_FN
-  project = op.init
+  begin
+    project = op.init
+  rescue Interrupt
+    issue_dir.rmdir
+    puts
+    exit 1
+  end
   project.save! fn
   puts "Ok, #{issue_dir} directory created successfully."
   exit
 when "reconfigure" # might not be able to load the project
-  op.do cmd, nil, config, ARGV
+  begin
+    op.do cmd, nil, config, ARGV
+  rescue Interrupt
+    puts
+    exit 1
+  end
   exit
 when "help"
   op.do cmd, nil, nil, ARGV
-- 
1.6.0.3



More information about the ditz-talk mailing list