Index: tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
===================================================================
--- tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java	(revision 1029960)
+++ tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java	(working copy)
@@ -17,22 +17,14 @@
 package org.apache.tika.cli;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-import java.lang.reflect.Field;
 import java.net.URL;
 import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
 
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.TransformerConfigurationException;
@@ -40,26 +32,26 @@
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+
 import org.apache.log4j.BasicConfigurator;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.SimpleLayout;
 import org.apache.log4j.WriterAppender;
-import org.apache.tika.config.TikaConfig;
-import org.apache.tika.detect.ContainerAwareDetector;
-import org.apache.tika.detect.Detector;
+
 import org.apache.tika.gui.TikaGUI;
-import org.apache.tika.io.TikaInputStream;
-import org.apache.tika.language.ProfilingHandler;
 import org.apache.tika.metadata.Metadata;
-import org.apache.tika.mime.MediaType;
-import org.apache.tika.mime.MediaTypeRegistry;
-import org.apache.tika.mime.MimeTypeException;
+import org.apache.tika.metadata.MetadataHelper;
 import org.apache.tika.parser.AutoDetectParser;
 import org.apache.tika.parser.ParseContext;
 import org.apache.tika.parser.Parser;
-import org.apache.tika.parser.html.BoilerpipeContentHandler;
 import org.apache.tika.sax.BodyContentHandler;
+
 import org.xml.sax.ContentHandler;
 import org.xml.sax.helpers.DefaultHandler;
 
@@ -74,12 +66,6 @@
         Logger.getRootLogger().setLevel(Level.INFO);
 
         TikaCLI cli = new TikaCLI();
-        for (int i = 0; i < args.length; i++) {
-            cli.process(args[i]);
-        }
-        if (cli.pipeMode) {
-            cli.process("-");
-        }
     }
 
     private interface OutputType {
@@ -104,12 +90,6 @@
         }
     };
 
-    private final OutputType TEXT_MAIN = new OutputType() {
-        public ContentHandler getContentHandler() throws Exception {
-            return new BoilerpipeContentHandler(getSystemOutWriter(encoding));
-        }
-    };
-    
     private final OutputType METADATA = new OutputType() {
         public ContentHandler getContentHandler() throws Exception {
             final PrintWriter writer =
@@ -121,19 +101,7 @@
                     for (String name : names) {
                         writer.println(name + ": " + metadata.get(name));
                     }
-                    writer.flush();
-                }
-            };
-        }
-    };
 
-    private final OutputType LANGUAGE = new OutputType() {
-        public ContentHandler getContentHandler() throws Exception{
-            final PrintWriter writer =
-                new PrintWriter(getSystemOutWriter(encoding));
-            return new ProfilingHandler() {
-                public void endDocument() {
-                    writer.println(getLanguage().getLanguage());
                     writer.flush();
                 }
             };
@@ -141,19 +109,12 @@
     };
 
     private ParseContext context;
-    
-    private Detector detector;
 
-    private AutoDetectParser parser;
+    private Parser parser;
 
     private Metadata metadata;
 
     private OutputType type = XML;
-    
-    private void initParser() {
-       parser = new AutoDetectParser(detector);
-       context.set(Parser.class, parser);
-    }
 
     /**
      * Output character encoding, or <code>null</code> for platform default
@@ -162,81 +123,47 @@
 
     private boolean pipeMode = true;
 
-    public TikaCLI() throws TransformerConfigurationException, IOException, MimeTypeException {
+    public TikaCLI() throws TransformerConfigurationException {
         context = new ParseContext();
-        detector = (new TikaConfig()).getMimeRepository();
-        initParser();
+        parser = new AutoDetectParser();
+        context.set(Parser.class, parser);
     }
 
-    public void process(String arg) throws Exception {
-        if (arg.equals("-?") || arg.equals("--help")) {
-            pipeMode = false;
-            usage();
-        } else if (arg.equals("-v") || arg.equals("--verbose")) {
-            Logger.getRootLogger().setLevel(Level.DEBUG);
-        } else if (arg.equals("-g") || arg.equals("--gui")) {
-            pipeMode = false;
-            TikaGUI.main(new String[0]);
-        } else if (arg.equals("--list-parser") || arg.equals("--list-parsers")) {
-            pipeMode = false;
-            displayParsers(false);
-        } else if (arg.equals("--list-parser-detail") || arg.equals("--list-parser-details")) {
-            pipeMode = false;
-            displayParsers(true);
-        } else if(arg.equals("--list-met-models")){
-            pipeMode = false;
-            displayMetModels();
-        } else if(arg.equals("--list-supported-types")){
-            pipeMode = false;
-            displaySupportedTypes();
-        } else if(arg.equals("--container-aware") || arg.equals("--container-aware-detector")) {
-           detector = new ContainerAwareDetector(detector);
-           initParser();
-        } else if (arg.startsWith("-e")) {
-            encoding = arg.substring("-e".length());
-        } else if (arg.startsWith("--encoding=")) {
-            encoding = arg.substring("--encoding=".length());
-        } else if (arg.equals("-x") || arg.equals("--xml")) {
-            type = XML;
-        } else if (arg.equals("-h") || arg.equals("--html")) {
-            type = HTML;
-        } else if (arg.equals("-t") || arg.equals("--text")) {
-            type = TEXT;
-        } else if (arg.equals("-T") || arg.equals("--text-main")) {
-            type = TEXT_MAIN;
-        } else if (arg.equals("-m") || arg.equals("--metadata")) {
-            type = METADATA;
-        } else if (arg.equals("-l") || arg.equals("--language")) {
-            type = LANGUAGE;
-        } else {
-            pipeMode = false;
-            metadata = new Metadata();
-            if (arg.equals("-")) {
-                parser.parse(
-                        System.in, type.getContentHandler(),
-                        metadata, context);
-            } else {
-                URL url;
-                File file = new File(arg);
-                if (file.isFile()) {
-                    url = file.toURI().toURL();
-                } else {
-                    url = new URL(arg);
-                }
-                InputStream input = TikaInputStream.get(url, metadata);
-                try {
-                    parser.parse(
-                            input, type.getContentHandler(),
-                            metadata, context);
-                } finally {
-                    input.close();
-                    System.out.flush();
-                }
-            }
-        }
-    }
+	 public void process(String arg[]) throws Exception {
+		 Options opts = new Options();
+		 opts.addOption(OptionBuilder.withLongOpt("--help").withDescription("Print this usage message").create("?"));
+		 opts.addOption(OptionBuilder.withLongOpt("--verbose").withDescription("Print debug level messages").create("v"));
+		 opts.addOption(OptionBuilder.withLongOpt("--gui").withDescription("Start the Apache Tika GUI").create("g"));
+		 opts.addOption(OptionBuilder.withLongOpt("--encoding").withDescription("Use Output encoding X").hasArg().withType(new String()).create("e"));
+		 opts.addOption(OptionBuilder.withLongOpt("--xml").withDescription("Output XHTML content (default)").create("x"));
+		 opts.addOption(OptionBuilder.withLongOpt("--html").withDescription("Output HTML content").create("h"));
+		 opts.addOption(OptionBuilder.withLongOpt("--text").withDescription("Output plain text content").create("t"));
+		 opts.addOption(OptionBuilder.withLongOpt("--metadata").withDescription("Output only metadata").create("m"));
+		 CommandLine cmdLine = new GnuParser().parse(opts, arg);
+		 if (cmdLine.hasOption("?")) {
+			 pipeMode = false;
+			 usage();
+		 } else if (cmdLine.hasOption("h")) {
+			 type = HTML;
+		 } else if (cmdLine.hasOption("t")) {
+			 type = TEXT;
+		 } else if (cmdLine.hasOption("m")) {
+			 type = METADATA;
+		 } else if (cmdLine.hasOption("x")) {
+			 type = XML;
+		 } else if (cmdLine.hasOption("v")) {
+			 Logger.getRootLogger().setLevel(Level.DEBUG);
+		 } else if (cmdLine.hasOption("g")) {
+			 pipeMode = false;
+			 TikaGUI.main(new String[0]);
+		 } else if (cmdLine.hasOption("e")) {
+			 encoding = cmdLine.getOptionValue("e");
+		 } else {
+			 pipeMode = false;
+		 }
+	 } 
 
-    private void usage() {
+	private void usage() {
         PrintStream out = System.out;
         out.println("usage: tika [option] [file]");
         out.println();
@@ -244,27 +171,11 @@
         out.println("    -?  or --help        Print this usage message");
         out.println("    -v  or --verbose     Print debug level messages");
         out.println("    -g  or --gui         Start the Apache Tika GUI");
-        out.println("");
+        out.println("    -eX or --encoding=X  Use output encoding X");
         out.println("    -x  or --xml         Output XHTML content (default)");
         out.println("    -h  or --html        Output HTML content");
         out.println("    -t  or --text        Output plain text content");
-        out.println("    -T  or --text-main   Output plain text content (main content only)");
         out.println("    -m  or --metadata    Output only metadata");
-        out.println("    -l  or --language    Output only language");
-        out.println("    -eX or --encoding=X  Use output encoding X");
-        out.println("");
-        out.println("    --container-aware-detector");
-        out.println("         Use the container aware detector, rather than the default mime");
-        out.println("         magic one. This is slower but more accurate on container formats.");
-        out.println("");
-        out.println("    --list-parsers");
-        out.println("         List the available document parsers");
-        out.println("    --list-parser-details");
-        out.println("         List the available document parsers, and their supported mime types");
-        out.println("    --list-met-models");
-        out.println("         List the available metadata models, and their supported keys");
-        out.println("    --list-supported-types");
-        out.println("         List all known media types and related information");
         out.println();
         out.println("Description:");
         out.println("    Apache Tika will parse the file(s) specified on the");
@@ -284,88 +195,7 @@
         out.println("    extract text content and metadata from the files.");
     }
 
-    private void displayMetModels(){
-        Class<?>[] modelClasses = Metadata.class.getInterfaces();
-        Arrays.sort(modelClasses, new Comparator<Class<?>>() {
-            public int compare(Class<?> o1, Class<?> o2) {
-                return o1.getName().compareTo(o2.getName());
-            }
-        });
-
-        for (Class<?> modelClass: modelClasses) {
-            // we don't care about internal Tika met classes
-            // if we do, then we can take this conditional out
-            if (modelClass.getSimpleName().contains("Tika")) {
-                System.out.println(modelClass.getSimpleName());
-                Field[] keyFields = modelClass.getFields();
-                Arrays.sort(keyFields, new Comparator<Field>() {
-                    public int compare(Field o1, Field o2) {
-                        return o1.getName().compareTo(o2.getName());
-                    }
-                });
-                for (Field keyField: keyFields) {
-                    System.out.println(" "+keyField.getName());
-                }
-            }
-        }
-    }
-
-    private void displayParsers(boolean includeMimeTypes) {
-        // Invert the map
-        Map<MediaType,Parser> supported = parser.getParsers();
-        Map<Parser,Set<MediaType>> parsers = new HashMap<Parser, Set<MediaType>>();
-        for(Entry<MediaType, Parser> e : supported.entrySet()) {
-            if (!parsers.containsKey(e.getValue())) {
-                parsers.put(e.getValue(), new HashSet<MediaType>());
-            }
-            parsers.get(e.getValue()).add(e.getKey());
-        }
-
-        // Get a nicely sorted list of the parsers
-        Parser[] sortedParsers = parsers.keySet().toArray(new Parser[parsers.size()]);
-        Arrays.sort(sortedParsers, new Comparator<Parser>() {
-            public int compare(Parser p1, Parser p2) {
-                String name1 = p1.getClass().getName();
-                String name2 = p2.getClass().getName();
-                return name1.compareTo(name2);
-            }
-        });
-
-        // Display
-        for (Parser p : sortedParsers) {
-            System.out.println(p.getClass().getName());
-            if (includeMimeTypes) {
-                for (MediaType mt : parsers.get(p)) {
-                    System.out.println("  " + mt);
-                }
-            }
-        }
-    }
-
     /**
-     * Prints all the known media types, aliases and matching parser classes.
-     */
-    private void displaySupportedTypes() {
-        MediaTypeRegistry registry = parser.getMediaTypeRegistry();
-        Map<MediaType, Parser> parsers = parser.getParsers();
-
-        for (MediaType type : registry.getTypes()) {
-            System.out.println(type);
-            for (MediaType alias : registry.getAliases(type)) {
-                System.out.println("  alias:     " + alias);
-            }
-            MediaType supertype = registry.getSupertype(type);
-            if (supertype != null) {
-                System.out.println("  supertype: " + supertype);
-            }
-            Parser parser = parsers.get(type);
-            if (parser != null) {
-                System.out.println("  parser:    " + parser.getClass().getName());
-            }
-        }
-    }
-
-    /**
      * Returns a {@link System#out} writer with the given output encoding.
      *
      * @see <a href="https://issues.apache.org/jira/browse/TIKA-277">TIKA-277</a>
Index: tika-app/pom.xml
===================================================================
--- tika-app/pom.xml	(revision 1029960)
+++ tika-app/pom.xml	(working copy)
@@ -42,6 +42,11 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.2</version>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>1.5.6</version>
