static int Main(string[] args) { OptionParser parser = new OptionParser(args); var jsOutOption = new OptionParser.OptionString(null, "--jsout", null, "Compress Javascript input files to the specified output file.", "OUTFILE"); var cssOutOption = new OptionParser.OptionString(null, "--cssout", null, "Compress CSS input files to the specified output file.", "OUTFILE"); parser.AddOption(jsOutOption); parser.AddOption(cssOutOption); parser.Parse(); //Arguments commandLine = new Arguments(args); if (parser.HelpSpecified()) { Console.WriteLine(String.Empty); Console.WriteLine("usage:"); Console.WriteLine("\tWebCompressor --jsout:OUTFILE INFILE..."); Console.WriteLine("\tWebCompressor --cssout:OUTFILE INFILE..."); Console.WriteLine("options:"); Console.WriteLine("\t-h, --help\t Show this help message and exit."); //Console.WriteLine("\t-j:, --jsdir:\t The path of the javacscript directory. All *.js files will be compressed recursively."); Console.WriteLine("\t-jo:, --jsout:\t Compress Javscript input files to specified output file."); //Console.WriteLine("\t-c:, --cssdir:\t The path of the css directory. All *.css files will be compressed recursively."); Console.WriteLine("\t-co:, --cssout:\t Compress CSS input files to specified output file."); return 0; } else { bool jsMode = jsOutOption.Value != null; bool cssMode = cssOutOption.Value != null; if (jsMode && cssMode) { Console.WriteLine("Cannot compress Javascript and CSS simultaneously."); return 1; } if (!jsMode && !cssMode) { Console.WriteLine("Please specify Javascript or CSS via the --jsout or --cssout options."); return 1; } if (jsMode) { List<string> jsIn = new List<string>(parser.PosArgs); string jsOut = jsOutOption.Value; Console.Write("Compressing Javascript..."); CompressJs(jsIn, jsOut); } if (cssMode) { List<string> cssIn = new List<string>(parser.PosArgs); string cssOut = cssOutOption.Value; Console.WriteLine("Compressing Css..."); CompressCss(cssIn, cssOut); } return 0; } }
public void SetUp() { iComplexParser = new OptionParser(); iEmptyParser = new OptionParser(); iOptionAlpha = new OptionParser.OptionString("-a", "--alpha", "ALPHA_DEFAULT", "ALPHA_DESC", "ALPHA_METAVAR"); iOptionBravo = new OptionParser.OptionBool("-b", "--bravo", "BRAVO_DESC"); iOptionCharlie = new OptionParser.OptionUint("-c", "--charlie", 12345, "CHARLIE_DESC", "CHARLIE_METAVAR"); iOptionDelta = new OptionParser.OptionInt("-d", "--delta", -54321, "DELTA_DESC", "DELTA_METAVAR"); iOptionQuebec = new OptionParser.OptionString(null, "--quebec", "QUEBEC_DEFAULT", "QUEBEC_DESC", "QUEBEC_METAVAR"); iOptionXRay = new OptionParser.OptionString("-x", null, "XRAY_DEFAULT", "XRAY_DESC", "XRAY_METAVAR"); iComplexParser.AddOption(iOptionAlpha); iComplexParser.AddOption(iOptionBravo); iComplexParser.AddOption(iOptionCharlie); iComplexParser.AddOption(iOptionDelta); iComplexParser.AddOption(iOptionQuebec); iComplexParser.AddOption(iOptionXRay); }