示例#1
0
        static void Main(string[] args)
        {
            var getopt = new Getopt(Assembly.GetExecutingAssembly().GetName().Name, args, "t:k:e:p:f:c:d:") { Opterr = false };

            string tag = null;
            string keyword = null;
            string extension = null;
            string path = null;
            string function = null;
            string charset = null;
            string fromCharset = null;

            int option;
            while (-1 != (option = getopt.getopt()))
            {
                switch (option)
                {
                    case 't': tag = getopt.Optarg; break;
                    case 'k': keyword = getopt.Optarg; break;
                    case 'e': extension = getopt.Optarg; break;
                    case 'p': path = getopt.Optarg; break;
                    case 'f': function = getopt.Optarg; break;
                    case 'c': charset = getopt.Optarg; break;
                    case 'd': fromCharset = getopt.Optarg; break;

                    default: PrintUsage(); return;
                }
            }

            if (keyword == null || extension == null || path == null)
            {
                PrintUsage(); return;
            }

            if (tag == null && function == null)
            {
                PrintUsage(); return;
            }

            try
            {
                IAspStringsParser tagParser = tag == null ? null : new AspStringsParser(tag);
                IAspStringsParser csParser = function == null ? null : new CSharpAspStringsParser(function);

                IAspStringsParser parser;
                if (tagParser != null && csParser != null)
                {
                    parser = new CompositeAspStringsParser(tagParser, csParser);
                }
                else
                {
                    parser = tagParser ?? csParser;
                }

                var extractor = new AspStringsExtractor(keyword, extension, charset, fromCharset, parser);
                extractor.Extract(path);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Failure processing files: {0}", ex.Message);
                return;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var getopt = new Getopt(Assembly.GetExecutingAssembly().GetName().Name, args, "t:k:e:p:f:c:d:")
            {
                Opterr = false
            };

            string tag         = null;
            string keyword     = null;
            string extension   = null;
            string path        = null;
            string function    = null;
            string charset     = null;
            string fromCharset = null;

            int option;

            while (-1 != (option = getopt.getopt()))
            {
                switch (option)
                {
                case 't': tag = getopt.Optarg; break;

                case 'k': keyword = getopt.Optarg; break;

                case 'e': extension = getopt.Optarg; break;

                case 'p': path = getopt.Optarg; break;

                case 'f': function = getopt.Optarg; break;

                case 'c': charset = getopt.Optarg; break;

                case 'd': fromCharset = getopt.Optarg; break;

                default: PrintUsage(); return;
                }
            }

            if (keyword == null || extension == null || path == null)
            {
                PrintUsage(); return;
            }

            if (tag == null && function == null)
            {
                PrintUsage(); return;
            }

            try
            {
                IAspStringsParser tagParser = tag == null ? null : new AspStringsParser(tag);
                IAspStringsParser csParser  = function == null ? null : new CSharpAspStringsParser(function);

                IAspStringsParser parser;
                if (tagParser != null && csParser != null)
                {
                    parser = new CompositeAspStringsParser(tagParser, csParser);
                }
                else
                {
                    parser = tagParser ?? csParser;
                }

                var extractor = new AspStringsExtractor(keyword, extension, charset, fromCharset, parser);
                extractor.Extract(path);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Failure processing files: {0}", ex.Message);
                return;
            }
        }