Created
October 10, 2016 16:21
-
-
Save localytics-gist/ef72841b2700106966bdf299f54e3214 to your computer and use it in GitHub Desktop.
Revisions
-
localytics-gist created this gist
Oct 10, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ require ‘thor’ require ‘thor/hollaback’ module MyProgram class Error < StandardError end class CLI class_option :debug, desc: 'Sets up debug mode', aliases: ['-d'], type: :boolean class_around :safe_execute desc ‘test [arg]’, ‘The test command’ def test(arg) raise Error, ‘Oh no!’ if arg == ‘fail’ end no_commands do def safe_execute yield rescue Error => error raise error if options[:debug] STDERR.puts error.message exit 1 end end end end