package folioxml.command;

import org.apache.commons.cli.*;

public class Main {

	
	public static Options getOptions(){
		Options options = new Options();
		options.addOption("type", true, "xml for raw xml, xhtml for xhtml, and simple-xhtml for simplified");
		options.addOption("exportfolder", true, " A subfolder to export the files to");
		return options;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    // create the parser
	    CommandLineParser parser = new PosixParser();
	    try {
	        // parse the command line arguments
	        CommandLine line = parser.parse( getOptions(), args );
	    //    line.getArgs()
	    }
	    catch( ParseException exp ) {
	        // oops, something went wrong
	        System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );
	    }

	}

}

@@ -31,247 +31,698 @@
 ort 
-org.apache.commons.cli.*;%0A%0Apublic class Main %7B%0A%0A%09%0A%09public static Options getOptions()%7B%0A%09%09Options options = new Options();%0A%09%09options.addOption(%22type%22, true, %22xml for raw xml, xhtml for xhtml, and simple-xhtml for simplified%22);%0A%09%09options.add
+folioxml.config.InfobaseSet;%0Aimport folioxml.config.TestConfig;%0Aimport folioxml.config.YamlInfobaseSet;%0Aimport folioxml.core.InvalidMarkupException;%0Aimport folioxml.export.ExportRunner;%0Aimport org.apache.commons.cli.*;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.nio.file.Paths;%0Aimport java.util.Map;%0A%0Apublic class Main %7B%0A%0A%09%0A%09public static Options getOptions()%7B%0A%09%09Options options = new Options();%0A%09%09//yaml file%0A%09%09//which configuration%0A%09%09//inventory, index, or export%0A%0A        Option config = new Option(%22config%22, true, %22Path to yaml configuration%22);%0A        config.setRequired(true);%0A        Option export = new 
 Opti
@@ -731,22 +731,16 @@
 (%22export
-folder
 %22, true,
@@ -745,47 +745,146 @@
 e, %22
- A subfolder to export the files to%22
+Name of config set to export%22);%0A        export.setRequired(true);%0A%0A        options.addOption(config);%0A        options.addOption(export
 );%0A
+%0A
 %09%09re
@@ -926,17 +926,20 @@
 gs%0A%09 */%0A
-%09
+    
 public s
@@ -968,16 +968,119 @@
 %5B%5D args)
+ throws IOException %7B%0A        run(args);%0A    %7D%0A%09public static int run(String%5B%5D args) throws IOException
  %7B%0A%09    
@@ -1252,56 +1252,1116 @@
 rse(
- getOptions(), args );%0A%09
+getOptions(), args);%0A%0A            String configPath = line.getOptionValue(%22config%22);%0A            String configName = line.getOptionValue(%22export%22);%0A%0A%0A            String fullConfigPath = Paths.get(configPath).toFile().getCanonicalPath();%0A            if (!Paths.get(fullConfigPath).toFile().exists())%7B%0A                System.err.println( %22Failed to locate yaml file %22 +fullConfigPath);%0A                return 2;%0A            %7D%0A%0A            InputStream privateYaml =  new FileInputStream(fullConfigPath);%0A            String workingDir = new File(%22.%22).getCanonicalPath();%0A            Map%3CString,InfobaseSet%3E configs = YamlInfobaseSet.parseYaml(workingDir, privateYaml);%0A%0A            if (!configs.containsKey(configName))%7B%0A                System.err.println(%22The yaml file does not contain a configuration '%22 + configName + %22'.%22);%0A        
     
-//
     
-line.getArgs()
+return 3;%0A            %7D%0A            System.out.println(%22Indexing...%22);%0A            new ExportRunner(configs.get(configName)).Index();%0A            System.out.println(%22Exporting...%22);%0A            new ExportRunner(configs.get(configName)).Export();%0A            return 0;
 %0A%09  
@@ -2466,17 +2466,16 @@
 println(
- 
 %22Parsing
@@ -2516,21 +2516,144 @@
 ge()
- 
 );%0A
-%09    %7D%0A%0A%09
+            return 1;%0A%09    %7D catch (InvalidMarkupException e) %7B%0A            e.printStackTrace();%0A            return 4;%0A        %7D%0A    
 %7D%0A%0A%7D

Create command-line class.