public override ICommandLineParserResult ParseArgs(string[] args)
        {
            Parser
            .Setup <int>('p', "port")
            .WithDescription($"Local port to listen on. Default: {DefaultPort}")
            .SetDefault(DefaultPort)
            .Callback(p => Port = p);

            Parser
            .Setup <int>('n', "nodeDebugPort")
            .WithDescription($"Port for node debugger to use. Default: value from launch.json or {DebuggerHelper.DefaultNodeDebugPort}")
            .SetDefault(DebuggerHelper.GetNodeDebuggerPort())
            .Callback(p => NodeDebugPort = p);

            Parser
            .Setup <TraceLevel>('d', "debugLevel")
            .WithDescription($"Console trace level (off, verbose, info, warning or error). Default: {DefaultDebugLevel}")
            .SetDefault(DefaultDebugLevel)
            .Callback(p => ConsoleTraceLevel = p);

            Parser
            .Setup <string>("cors")
            .WithDescription($"A comma separated list of CORS origins with no spaces. Example: https://functions.azure.com,https://functions-staging.azure.com")
            .SetDefault(string.Empty)
            .Callback(c => CorsOrigins = c);

            Parser
            .Setup <int>('t', "timeout")
            .WithDescription($"Timeout for on the functions host to start in seconds. Default: {DefaultTimeout} seconds.")
            .SetDefault(DefaultTimeout)
            .Callback(t => Timeout = t);

            Parser
            .Setup <bool>("useHttps")
            .WithDescription("Bind to https://localhost:{port} rather than http://localhost:{port}. By default it creates and trusts a certificate.")
            .SetDefault(false)
            .Callback(s => UseHttps = s);

            Parser
            .Setup <bool>("ignoreHostJsonNotFound")
            .WithDescription($"Default is false. Ignores the check for {ScriptConstants.HostMetadataFileName} in current directory then up until it finds one.")
            .SetDefault(false)
            .Callback(f => IgnoreHostJsonNotFound = f);

            Parser
            .Setup <DebuggerType>("debug")
            .WithDescription("Default is None. Options are VSCode and VS")
            .SetDefault(DebuggerType.None)
            .Callback(d => Debugger = d);

            return(Parser.Parse(args));
        }
        public override ICommandLineParserResult ParseArgs(string[] args)
        {
            var hostSettings = _secretsManager.GetHostStartSettings();

            Parser
            .Setup <int>('p', "port")
            .WithDescription($"Local port to listen on. Default: {DefaultPort}")
            .SetDefault(hostSettings.LocalHttpPort == default(int) ? DefaultPort : hostSettings.LocalHttpPort)
            .Callback(p => Port = p);

            Parser
            .Setup <int>('n', "nodeDebugPort")
            .WithDescription($"Port for node debugger to use. Default: value from launch.json or {DebuggerHelper.DefaultNodeDebugPort}")
            .SetDefault(DebuggerHelper.GetNodeDebuggerPort())
            .Callback(p => NodeDebugPort = p);

            Parser
            .Setup <TraceLevel>('d', "debugLevel")
            .WithDescription($"Console trace level (off, verbose, info, warning or error). Default: {DefaultDebugLevel}")
            .SetDefault(DefaultDebugLevel)
            .Callback(p => ConsoleTraceLevel = p);

            Parser
            .Setup <string>("cors")
            .WithDescription($"A comma separated list of CORS origins with no spaces. Example: https://functions.azure.com,https://functions-staging.azure.com")
            .SetDefault(hostSettings.Cors ?? string.Empty)
            .Callback(c => CorsOrigins = c);

            Parser
            .Setup <int>('t', "timeout")
            .WithDescription($"Timeout for on the functions host to start in seconds. Default: {DefaultTimeout} seconds.")
            .SetDefault(DefaultTimeout)
            .Callback(t => Timeout = t);

            Parser
            .Setup <bool>("useHttps")
            .WithDescription("Bind to https://localhost:{port} rather than http://localhost:{port}. By default it creates and trusts a certificate.")
            .SetDefault(false)
            .Callback(s => UseHttps = s);

            Parser
            .Setup <DebuggerType>("debug")
            .WithDescription("Default is None. Options are VSCode and VS")
            .SetDefault(DebuggerType.None)
            .Callback(d => Debugger = d);

            return(Parser.Parse(args));
        }
예제 #3
0
        /// <summary>
        /// Sets a colour for the console output
        /// </summary>
        /// <param name="dType"></param>
        private static void setColour(DebuggerType dType)
        {
            switch (dType)
            {
            case DebuggerType.Normal:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case DebuggerType.Event:
                Console.ForegroundColor = ConsoleColor.Green;
                break;

            case DebuggerType.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            default:
                Console.ForegroundColor = ConsoleColor.Blue;
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Gets an object that enables debugging of a process.
        /// </summary>
        /// <param name="targetProcess">The process to debug.</param>
        /// <param name="debugger">The debugger implementation to use.</param>
        /// <returns>An object that enables debugging of a process.</returns>
        public static IDebugger Create(Process targetProcess, DebuggerType debugger = DebuggerType.Default)
        {
            switch (debugger)
            {
            case DebuggerType.WinDbg:
                return(new DebugEngine(targetProcess));

            case DebuggerType.Default:
            default:
                OperatingSystem os         = Environment.OSVersion;
                PlatformID      platformid = os.Platform;
                Exception       ex;

                switch (platformid)
                {
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.WinCE:
                    return(new DebugEngine(targetProcess));

                case PlatformID.Unix:
                    ex = new Exception("Unix operating system is not supported");
                    break;

                case PlatformID.MacOSX:
                    ex = new Exception("MacOSX operating system is not supported");
                    break;

                default:
                    ex = new Exception("Unknown operating system");
                    break;
                }

                Logger.Log(LogLevel.Fatal, "Unsupported Operating System", ex);
                throw ex;
            }
        }
예제 #5
0
        /// <summary>
        /// Gets an object that enables debugging of a process.
        /// </summary>
        /// <returns>An object that enables debugging of a process.</returns>
        public static IDebugger GetDebugger(DebuggerType debugger = DebuggerType.Default)
        {
            switch (debugger)
            {
            case DebuggerType.WinDbg:
                return(DebuggerFactory.windowsDebuggerInstance.Value);

            case DebuggerType.Default:
            default:
                OperatingSystem os         = Environment.OSVersion;
                PlatformID      platformid = os.Platform;
                Exception       ex;

                switch (platformid)
                {
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.WinCE:
                    return(windowsDebuggerInstance.Value);

                case PlatformID.Unix:
                    ex = new Exception("Unix operating system is not supported");
                    break;

                case PlatformID.MacOSX:
                    ex = new Exception("MacOSX operating system is not supported");
                    break;

                default:
                    ex = new Exception("Unknown operating system");
                    break;
                }

                Logger.Log(LogLevel.Fatal, "Unsupported Operating System", ex);
                throw ex;
            }
        }
예제 #6
0
 /// <summary>
 /// Formats a string to the console
 /// </summary>
 /// <param name="dType"></param>
 /// <param name="message"></param>
 /// <param name="args"></param>
 public static void WriteLine(DebuggerType dType, string message, params object[] args)
 {
     setColour(dType);
     Console.WriteLine("[{0}] {1}", DateTime.Now.ToLongTimeString(), string.Format(message, args));
 }