Document everything with YARD and fix some bugs along the way.
[mailshears.git] / lib / common / user_interface.rb
1 # Class methods for the creation and manipulation of our command-line
2 # user interface.
3 #
4 class UserInterface
5
6 # Construct a usage string showing how to invoke the program.
7 #
8 # @param program_name [String] the name of this program, used to
9 # construct the usage string.
10 #
11 # @return [String] a string showing the format of a correct program
12 # invocation.
13 #
14 def self.usage(program_name)
15 return "#{program_name} [prune | rm <target> | mv <src> <dst>]"
16 end
17
18
19 # Construct the header that precedes our other output. An example is,
20 #
21 # mailshears, 2015-11-06 09:57:06 -0500 (Plugin: PrunePlugin)
22 # ------------------------------------------------------------
23 #
24 # @param program_name [String] the name of this program, to appear
25 # in the header.
26 #
27 # @param plugin_name [String] the name of the mode (prune, mv, etc.)
28 # plugin that is being run.
29 #
30 # @return [String] a string containing the output header.
31 #
32 def self.make_header(program_name, plugin_name)
33 header = "#{program_name}, "
34
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()
39 else
40 # Fall back to whatever this looks like.
41 header += current_time.to_s()
42 end
43
44 header += ' (Plugin: ' + plugin_name + ")\n"
45 header += '-' * header.size() # Underline the header.
46
47 return header
48 end
49
50
51 end