X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fcommon%2Fuser_interface.rb;h=00d3d7e52ddf649547503384301c304d613ad173;hp=6a60d041b56a39465024b04add715de23d13df5a;hb=df4e02ebf6a4e28a58abcb298a4442a245ad0b15;hpb=d0bfa37fb4be739b31dd97c493764ca19a160182 diff --git a/lib/common/user_interface.rb b/lib/common/user_interface.rb index 6a60d04..00d3d7e 100644 --- a/lib/common/user_interface.rb +++ b/lib/common/user_interface.rb @@ -1,19 +1,51 @@ -def make_header(program_name, plugin_name) - # The header that we output before the list of domains/users. - # Just the path of this script, the current time, and the plugin name. - header = "#{program_name}, " - - current_time = Time.now() - if current_time.respond_to?(:iso8601) - # Somehow this method is missing on some machines. - header += current_time.iso8601.to_s - else - # Fall back to whatever this looks like. - header += current_time.to_s +# Class methods for the creation and manipulation of our command-line +# user interface. +# +class UserInterface + + # Construct a usage string showing how to invoke the program. + # + # @param program_name [String] the name of this program, used to + # construct the usage string. + # + # @return [String] a string showing the format of a correct program + # invocation. + # + def self.usage(program_name) + return "#{program_name} [prune | rm | mv ]" + end + + + # Construct the header that precedes our other output. An example is, + # + # mailshears, 2015-11-06 09:57:06 -0500 (Plugin: PrunePlugin) + # ------------------------------------------------------------ + # + # @param program_name [String] the name of this program, to appear + # in the header. + # + # @param plugin_name [String] the name of the mode (prune, mv, etc.) + # plugin that is being run. + # + # @return [String] a string containing the output header. + # + def self.make_header(program_name, plugin_name) + header = "#{program_name}, " + + current_time = Time.now() + if current_time.respond_to?(:iso8601) + # Somehow this method is missing on some machines. + header += current_time.iso8601.to_s() + else + # Fall back to whatever this looks like. + header += current_time.to_s() + end + + header += ' (Plugin: ' + plugin_name + ")\n" + header += '-' * header.size() # Underline the header. + + return header end - header += ' (Plugin: ' + plugin_name + ")\n" - header += '-' * header.size # Underline the header. - return header end