lib/sifttter_redux/cli_message.rb in sifttter-redux-0.3.3 vs lib/sifttter_redux/cli_message.rb in sifttter-redux-0.3.4
- old
+ new
@@ -1,5 +1,7 @@
+require File.join(File.dirname(__FILE__), 'string_extensions.rb')
+
module SifttterRedux
# ======================================================
# CliManager Module
# Singleton to manage common CLI interfacing
# ======================================================
@@ -34,22 +36,26 @@
# @param m2 The closing message to output
# @param multiline Whether the message should be multiline
# @return Void
# ----------------------------------------------------
def self.info_block(m1, m2 = 'Done.', multiline = false)
- if multiline
- info(m1)
- else
- print "---> INFO: #{ m1 }".blue
- end
+ if block_given?
+ if multiline
+ info(m1)
+ else
+ print "---> INFO: #{ m1 }".blue
+ end
- yield
+ yield
- if multiline
- info(m2)
+ if multiline
+ info(m2)
+ else
+ puts m2.blue
+ end
else
- puts m2.blue
+ fail ArgumentError, 'Did not specify a valid block'
end
end
# ----------------------------------------------------
# prompt method
@@ -90,16 +96,20 @@
# @param m2 The closing message to output
# @param multiline A multiline message or not
# @return Void
# ----------------------------------------------------
def self.section_block(m, multiline = true)
- if multiline
- section(m)
+ if block_given?
+ if multiline
+ section(m)
+ else
+ print "#### #{ m }".purple
+ end
+
+ yield
else
- print "#### #{ m }".purple
+ fail ArgumentError, 'Did not specify a valid block'
end
-
- yield
end
# ----------------------------------------------------
# success method
#