]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/user_interface.rb
Document everything with YARD and fix some bugs along the way.
[mailshears.git] / lib / common / user_interface.rb
index 6a60d041b56a39465024b04add715de23d13df5a..00d3d7e52ddf649547503384301c304d613ad173 100644 (file)
@@ -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 <target> | mv <src> <dst>]"
+  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