]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/user_interface.rb
1 # Class methods for the creation and manipulation of our command-line
6 # Construct a usage string showing how to invoke the program.
8 # @param program_name [String] the name of this program, used to
9 # construct the usage string.
11 # @return [String] a string showing the format of a correct program
14 def self.usage(program_name
)
15 return "#{program_name} [--help] [prune | rm <target> | mv <src> <dst>]"
19 # Construct the header that precedes our other output. An example is,
21 # mailshears, 2015-11-06 09:57:06 -0500 (Plugin: PrunePlugin)
22 # ------------------------------------------------------------
24 # @param program_name [String] the name of this program, to appear
27 # @param plugin_name [String] the name of the mode (prune, mv, etc.)
28 # plugin that is being run.
30 # @return [String] a string containing the output header.
32 def self.make_header(program_name
, plugin_name
)
33 header
= "#{program_name}, "
35 current_time
= Time
.now()
36 if current_time
.respond_to
?(:iso8601)
37 # Somehow this method is missing on some machines.
38 header +
= current_time
.iso8601
.to_s()
40 # Fall back to whatever this looks like.
41 header +
= current_time
.to_s()
44 header +
= ' (Plugin: ' + plugin_name +
")\n"
46 # Underline the header, accounting for the newline.
47 header +
= '-' * (header
.size() - 1)