Ejemplo n.º 1
0
            /// <summary>
            /// Parses the given command line.
            /// </summary>
            public CommandLineOptions(string[] args)
            {
                UseColorConsoleOutput = true;
                Arguments             = new List <string>();

                bool no_more_switches = false;

                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    if (arg.Length == 0)
                    {
                        continue;
                    }

                    if (arg[0] == '/')
                    {
                        arg = "-" + arg.Substring(1);
                    }

                    switch (arg.ToLowerInvariant())
                    {
                    case "-64":
                    case "-x64":
                    case "-ia64":
                    case "-win64":
                    case "-bit:64":
                    case "-bits:64":
                    {
                        TargetPlatform64Bit = true;
                        break;
                    }

                    case "-32":
                    case "-x86":
                    case "-ia32":
                    case "-win32":
                    case "-bit:32":
                    case "-bits:32":
                    {
                        TargetPlatform64Bit = false;
                        break;
                    }

                    case "-ansi":
                    case "-ansi+":
                    case "-unicode-":
                    {
                        TargetPlatformAnsi = true;
                        break;
                    }

                    case "-unicode":
                    case "-unicode+":
                    case "-ansi-":
                    {
                        TargetPlatformAnsi = false;
                        break;
                    }

                    case "-wintypes-":
                    case "-plaintypes":
                    case "-plaintypes+":
                    {
                        UsePlainCDataTypes = true;
                        break;
                    }

                    case "-wintypes":
                    case "-wintypes+":
                    case "-plaintypes-":
                    {
                        UsePlainCDataTypes = false;
                        break;
                    }

                    case "-color":
                    case "-color+":
                    case "-bw-":
                    {
                        UseColorConsoleOutput = true;
                        break;
                    }

                    case "-bw":
                    case "-bw+":
                    case "-color-":
                    {
                        UseColorConsoleOutput = false;
                        break;
                    }

                    case "-inout":
                    case "-direction":
                    {
                        PrintMarshalDirection = true;
                        break;
                    }

                    case "-nologo":
                    case "-logo-":
                    {
                        SuppressLogo = true;
                        break;
                    }

                    case "-msg-":
                    case "-nomsg":
                    {
                        SuppressMessages = true;
                        break;
                    }

                    case "-types-":
                    case "-notypes":
                    {
                        SuppressTypeDefinitions = true;
                        break;
                    }

                    case "-?":
                    case "-help":
                    {
                        PrintLogo();
                        PrintHelp();
                        Environment.Exit(0);
                        break;
                    }

                    case "-file":
                    {
                        if (i + 1 < args.Length)
                        {
                            AssemblyFilePath = args[++i];
                            try
                            {
                                if (AssemblyFilePath == "mscorlib")
                                {
                                    AssemblyFilePath = typeof(int).Assembly.FullName;
                                }
                                else
                                {
                                    AssemblyFilePath = System.IO.Path.GetFullPath(AssemblyFilePath);
                                }
                            }
                            catch (Exception)
                            { }
                        }
                        break;
                    }

                    case "--":
                    {
                        no_more_switches = true;
                        break;
                    }

                    default:
                    {
                        if (arg[0] == '-' && !no_more_switches)
                        {
                            if (!SuppressLogo)
                            {
                                PrintLogo();
                            }

                            using (TextWriterPrinter twp = new TextWriterPrinter(Console.Error))
                            {
                                ConsoleErrors.ERROR_UnrecognizedOption.PrintTo(twp, args[i]);
                            }
                            Environment.Exit(1);
                        }
                        else
                        {
                            Arguments.Add(args[i]);
                        }
                        break;
                    }
                    }
                }

                if (!SuppressLogo)
                {
                    PrintLogo();
                }

                if (String.IsNullOrEmpty(AssemblyFilePath))
                {
                    using (TextWriterPrinter twp = new TextWriterPrinter(Console.Error))
                    {
                        ConsoleErrors.ERROR_AssemblyFileNotSpecified.PrintTo(twp);
                    }
                    Environment.Exit(1);
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Parses the given command line.
            /// </summary>
            public CommandLineOptions(string[] args)
            {
                UseColorConsoleOutput = true;
                Arguments = new List<string>();

                bool no_more_switches = false;

                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    if (arg.Length == 0) continue;

                    if (arg[0] == '/') arg = "-" + arg.Substring(1);

                    switch (arg.ToLowerInvariant())
                    {
                        case "-64":
                        case "-x64":
                        case "-ia64":
                        case "-win64":
                        case "-bit:64":
                        case "-bits:64":
                        {
                            TargetPlatform64Bit = true;
                            break;
                        }

                        case "-32":
                        case "-x86":
                        case "-ia32":
                        case "-win32":
                        case "-bit:32":
                        case "-bits:32":
                        {
                            TargetPlatform64Bit = false;
                            break;
                        }

                        case "-ansi":
                        case "-ansi+":
                        case "-unicode-":
                        {
                            TargetPlatformAnsi = true;
                            break;
                        }

                        case "-unicode":
                        case "-unicode+":
                        case "-ansi-":
                        {
                            TargetPlatformAnsi = false;
                            break;
                        }

                        case "-wintypes-":
                        case "-plaintypes":
                        case "-plaintypes+":
                        {
                            UsePlainCDataTypes = true;
                            break;
                        }

                        case "-wintypes":
                        case "-wintypes+":
                        case "-plaintypes-":
                        {
                            UsePlainCDataTypes = false;
                            break;
                        }

                        case "-color":
                        case "-color+":
                        case "-bw-":
                        {
                            UseColorConsoleOutput = true;
                            break;
                        }

                        case "-bw":
                        case "-bw+":
                        case "-color-":
                        {
                            UseColorConsoleOutput = false;
                            break;
                        }

                        case "-inout":
                        case "-direction":
                        {
                            PrintMarshalDirection = true;
                            break;
                        }

                        case "-nologo":
                        case "-logo-":
                        {
                            SuppressLogo = true;
                            break;
                        }

                        case "-msg-":
                        case "-nomsg":
                        {
                            SuppressMessages = true;
                            break;
                        }

                        case "-types-":
                        case "-notypes":
                        {
                            SuppressTypeDefinitions = true;
                            break;
                        }

                        case "-?":
                        case "-help":
                        {
                            PrintLogo();
                            PrintHelp();
                            Environment.Exit(0);
                            break;
                        }

                        case "-file":
                        {
                            if (i + 1 < args.Length)
                            {
                                AssemblyFilePath = args[++i];
                                try
                                {
                                    if (AssemblyFilePath == "mscorlib")
                                    {
                                        AssemblyFilePath = typeof(int).Assembly.FullName;
                                    }
                                    else
                                    {
                                        AssemblyFilePath = System.IO.Path.GetFullPath(AssemblyFilePath);
                                    }
                                }
                                catch (Exception)
                                { }
                            }
                            break;
                        }

                        case "--":
                        {
                            no_more_switches = true;
                            break;
                        }

                        default:
                        {
                            if (arg[0] == '-' && !no_more_switches)
                            {
                                if (!SuppressLogo)
                                {
                                    PrintLogo();
                                }

                                using (var twp = new TextWriterPrinter(Console.Error))
                                {
                                    ConsoleErrors.ERROR_UnrecognizedOption.PrintTo(twp, args[i]);
                                }
                                Environment.Exit(1);
                            }
                            else Arguments.Add(args[i]);
                            break;
                        }
                    }
                }

                if (!SuppressLogo)
                {
                    PrintLogo();
                }

                if (String.IsNullOrEmpty(AssemblyFilePath))
                {
                    using (var twp = new TextWriterPrinter(Console.Error))
                    {
                        ConsoleErrors.ERROR_AssemblyFileNotSpecified.PrintTo(twp);
                    }
                    Environment.Exit(1);
                }
            }