Exemple #1
0
        public static bool GetOptions(string[] args, String sopts, LongOpt[] lopts, Options options, out StringBuilder message)
        {
            message = new StringBuilder();
            Getopt.Getopt getopt = new Getopt.Getopt(
                Assembly.GetExecutingAssembly().GetName().Name,
                args, sopts, lopts)
            {
                Opterr = false
            };

            options.Verbose   = false;
            options.ShowUsage = false;
            options.Recursive = false;
            options.Overwrite = true;

            int option;

            while ((option = getopt.getopt()) != -1)
            {
                switch (option)
                {
                case 1:
                    options.InputFiles.Add(getopt.Optarg);
                    break;

                case 2:
                    options.Recursive = true;
                    break;

                case 3:
                    options.SearchPatterns.Add(getopt.Optarg);
                    break;

                case 4:
                    options.SetEncoding(getopt.Optarg);
                    break;

                case 5:
                    options.DetectEncoding = true;
                    break;

                case ':':
                    message.AppendFormat("Option '{0}' requires an argument", getopt.OptoptStr);
                    return(false);

                case '?':
                    message.AppendFormat("Invalid option '{0}'", getopt.OptoptStr);
                    return(false);

                case 'f':
                    string fileList = getopt.Optarg;
                    Utils.FileUtils.ReadStrings(fileList, options.InputFiles);
                    break;

                case 'j':
                    options.Overwrite = false;
                    break;

                case 'o':
                    options.OutFile = getopt.Optarg;
                    break;

                case 'D':
                    options.InputDirs.Add(getopt.Optarg);
                    break;

                case 'v':
                    options.Verbose = true;
                    break;

                case 'h':
                    options.ShowUsage = true;
                    return(true);

                default:
                    PrintUsage();
                    return(false);
                }
            }

            if (getopt.Opterr)
            {
                message.AppendLine();
                message.Append("Error in command line options. Use -h to read options usage");
                return(false);
            }
            return(true);
        }
Exemple #2
0
        public static bool GetOptions(string[] args, String sopts, LongOpt[] lopts, Options options, out StringBuilder message)
        {
            message = new StringBuilder();
            Getopt.Getopt getopt = new Getopt.Getopt(
                Assembly.GetExecutingAssembly().GetName().Name,
                args, sopts, lopts)
                {
                    Opterr = false
                };

            options.Mode = Mode.SateliteAssembly;
            options.Verbose = false;
            options.CompilerName = Path.DirectorySeparatorChar == '/' ? "mcs" : "csc";
            options.ShowUsage = false;
            options.CheckFormat = false;
            options.DebugMode = false;

            int option;
            while ((option = getopt.getopt()) != -1)
            {
                switch (option)
                {
                case 1:
                    options.InputFiles.Add(getopt.Optarg);
                    break;
                case 2:
                    options.CheckFormat = true;
                    break;
                case 3:
                    options.Mode = Mode.Resources;
                    break;
                case 4:
                    options.DebugMode = true;
                    Trace.WriteLine("Debug mode is ON");
                    break;
                case '5':
                    options.CompilerName = getopt.Optarg;
                    break;
                case ':':
                    message.AppendFormat("Option {0} requires an argument", getopt.OptoptStr);
                    return false;
                case '?':
                    message.AppendFormat("Invalid option '{0}'", getopt.OptoptStr);
                    return false;
                case 'r':
                    options.BaseName = getopt.Optarg;
                    break;
                case 'o':
                    options.OutFile = getopt.Optarg;
                    break;
                case 'd':
                    options.OutDir = getopt.Optarg;
                    break;
                case 'l':
                    options.LocaleStr = getopt.Optarg;
                    break;
                case 'L':
                    options.LibDir = getopt.Optarg;
                    break;
                case 'v':
                    options.Verbose = true;
                    break;
                case 'h':
                    options.ShowUsage = true;
                    return true;
                default:
                    PrintUsage();
                    return false;
                }
            }

            if (getopt.Opterr)
            {
                message.AppendLine();
                message.Append("Error in command line options. Use -h to read options usage");
                return false;
            }
            return true;
        }
Exemple #3
0
        public static bool GetOptions(string[] args, String sopts, LongOpt[] lopts, Options options, out StringBuilder message)
        {
            message = new StringBuilder();
            Getopt.Getopt getopt = new Getopt.Getopt(
                Assembly.GetExecutingAssembly().GetName().Name,
                args, sopts, lopts)
            {
                Opterr = false
            };

            options.Mode         = Mode.SateliteAssembly;
            options.Verbose      = false;
            options.CompilerName = Path.DirectorySeparatorChar == '/' ? "mcs" : "csc";
            options.ShowUsage    = false;
            options.CheckFormat  = false;
            options.DebugMode    = false;

            int option;

            while ((option = getopt.getopt()) != -1)
            {
                switch (option)
                {
                case 1:
                    options.InputFiles.Add(getopt.Optarg);
                    break;

                case 2:
                    options.CheckFormat = true;
                    break;

                case 3:
                    options.Mode = Mode.Resources;
                    break;

                case 4:
                    options.DebugMode = true;
                    Trace.WriteLine("Debug mode is ON");
                    break;

                case '5':
                    options.CompilerName = getopt.Optarg;
                    break;

                case ':':
                    message.AppendFormat("Option {0} requires an argument", getopt.OptoptStr);
                    return(false);

                case '?':
                    message.AppendFormat("Invalid option '{0}'", getopt.OptoptStr);
                    return(false);

                case 'r':
                    options.BaseName = getopt.Optarg;
                    break;

                case 'o':
                    options.OutFile = getopt.Optarg;
                    break;

                case 'd':
                    options.OutDir = getopt.Optarg;
                    break;

                case 'l':
                    options.LocaleStr = getopt.Optarg;
                    break;

                case 'L':
                    options.LibDir = getopt.Optarg;
                    break;

                case 'v':
                    options.Verbose = true;
                    break;

                case 'h':
                    options.ShowUsage = true;
                    return(true);

                default:
                    PrintUsage();
                    return(false);
                }
            }

            if (getopt.Opterr)
            {
                message.AppendLine();
                message.Append("Error in command line options. Use -h to read options usage");
                return(false);
            }
            return(true);
        }
Exemple #4
0
        public static bool GetOptions(string[] args, String sopts, LongOpt[] lopts, Options options, out StringBuilder message)
        {
            message = new StringBuilder();
            Getopt.Getopt getopt = new Getopt.Getopt(
                Assembly.GetExecutingAssembly().GetName().Name,
                args, sopts, lopts)
                {
                    Opterr = false
                };

            options.Verbose = false;
            options.ShowUsage = false;
            options.Recursive = false;
            options.Overwrite = true;

            int option;
            while ((option = getopt.getopt()) != -1)
            {
                switch (option)
                {
                case 1:
                    options.InputFiles.Add(getopt.Optarg);
                    break;
                case 2:
                    options.Recursive = true;
                    break;
                case 3:
                    options.SearchPatterns.Add(getopt.Optarg);
                    break;
                case 4:
                    options.SetEncoding(getopt.Optarg);
                    break;
                case 5:
                    options.DetectEncoding = true;
                    break;
                case ':':
                    message.AppendFormat("Option '{0}' requires an argument", getopt.OptoptStr);
                    return false;
                case '?':
                    message.AppendFormat("Invalid option '{0}'", getopt.OptoptStr);
                    return false;
                case 'f':
                    string fileList = getopt.Optarg;
                    Utils.FileUtils.ReadStrings(fileList, options.InputFiles);
                    break;
                case 'j':
                    options.Overwrite = false;
                    break;
                case 'o':
                    options.OutFile = getopt.Optarg;
                    break;
                case 'D':
                    options.InputDirs.Add(getopt.Optarg);
                    break;
                case 'v':
                    options.Verbose = true;
                    break;
                case 'h':
                    options.ShowUsage = true;
                    return true;
                default:
                    PrintUsage();
                    return false;
                }
            }

            if (getopt.Opterr)
            {
                message.AppendLine();
                message.Append("Error in command line options. Use -h to read options usage");
                return false;
            }
            return true;
        }
Exemple #5
0
        public static KMeansOptions getOptions(string[] args)
        {
            Getopt.Getopt g       = new Getopt.Getopt("KMeans", args, "cr:x:i:m:T:e:bR:X:K:I:vV:gd:E:");
            KMeansOptions options = new KMeansOptions();

            try {
                int c;
                while ((c = g.getopt()) != -1)
                {
                    switch (c)
                    {
                    case 'g':
                        options.m_bGenerateData = true;
                        break;

                    case 'd':
                        options.m_nGenerateDims = Int32.Parse(g.Optarg);
                        break;

                    case 'E':
                        options.m_nGenerateElems = Int32.Parse(g.Optarg);
                        break;

                    case 'v':
                        options.m_bVerbose = true;
                        break;

                    case 'V':
                        options.m_vImplementations[g.Optarg] = null;
                        break;

                    case 'X':
                        options.m_nMaximumThreadsSweep = Int32.Parse(g.Optarg);
                        break;

                    case 'K':
                        options.m_nPartitionSize = Int32.Parse(g.Optarg);
                        break;

                    case 'R':
                        options.m_nRandomSeed = Int32.Parse(g.Optarg);
                        break;

                    case 'c':
                        options.m_bCheckResult = true;
                        break;

                    case 'C':
                        options.m_bComparePerformance = true;
                        break;

                    case 'r':
                        options.m_nTotalRuns = Int16.Parse(g.Optarg);
                        break;

                    case 'T':
                        options.m_fConvergenceThreshold = float.Parse(g.Optarg);
                        break;

                    case 'e':
                        options.m_fEpsilon = float.Parse(g.Optarg);
                        break;

                    case 'x':
                        options.m_nMinimumThreadsSweep = int.Parse(g.Optarg);
                        break;

                    case 'i':
                        options.m_strFileName = g.Optarg;
                        break;

                    case 'I':
                        options.m_nMaxIterations = int.Parse(g.Optarg);
                        break;

                    case 'm':
                        options.m_nClusters = int.Parse(g.Optarg);
                        break;

                    case 'b':
                        options.m_bBinaryInput = true;
                        break;

                    case 'h':
                        PrintUsage();
                        return(null);

                    default:
                        Console.WriteLine("Unknown option: " + (Char)c);
                        PrintUsage();
                        return(null);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("Options exception: " + e.Message);
                PrintUsage();
                return(null);
            }
            return(options);
        }