private async Task <Uri> DiscoverServer(bool noInteractive)
        {
            var hostSettings = _secretsManager.GetHostStartSettings();

            if (hostSettings.LocalHttpPort != default(int))
            {
                return(new Uri($"http://localhost:{hostSettings.LocalHttpPort}"));
            }

            return(await RecursiveDiscoverServer(0, noInteractive));
        }
        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
        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 <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 <bool>("cors-credentials")
            .WithDescription($"Allow cross-origin authenticated requests (i.e. cookies and the Authentication header)")
            .SetDefault(hostSettings.CorsCredentials)
            .Callback(v => CorsCredentials = v);

            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 <string>("cert")
            .WithDescription("for use with --useHttps. The path to a pfx file that contains a private key")
            .Callback(c => CertPath = c);

            Parser
            .Setup <string>("password")
            .WithDescription("to use with --cert. Either the password, or a file that contains the password for the pfx file")
            .Callback(p => CertPassword = p);

            Parser
            .Setup <string>("language-worker")
            .WithDescription("Arguments to configure the language worker.")
            .Callback(w => LanguageWorkerSetting = w);

            Parser
            .Setup <bool>("no-build")
            .WithDescription("Do not build current project before running. For dotnet projects only. Default is set to false.")
            .SetDefault(false)
            .Callback(b => NoBuild = b);

            Parser
            .Setup <bool>("enableAuth")
            .WithDescription("Enable full authentication handling pipeline.")
            .SetDefault(false)
            .Callback(e => EnableAuth = e);

            Parser
            .Setup <List <string> >("functions")
            .WithDescription("A space seperated list of functions to load.")
            .Callback(f => EnabledFunctions = f);

            Parser
            .Setup <bool>("skip-azure-storage-check")
            .WithDescription("Skip the check for AzureWebJobsStorage being set. WARNING: Proceed with caution, only set this flag if you are sure you know what you're doing.")
            .SetDefault(false)
            .Callback(skip => SkipAzureStorageCheck = skip);

            Parser
            .Setup <bool>("verbose")
            .WithDescription("When false, hides system logs other than warnings and errors.")
            .SetDefault(false)
            .Callback(v => VerboseLogging = v);

            var  parserResult            = base.ParseArgs(args);
            bool verboseLoggingArgExists = parserResult.UnMatchedOptions.Any(o => o.LongName.Equals("verbose", StringComparison.OrdinalIgnoreCase));

            // Input args do not contain --verbose flag
            if (!VerboseLogging.Value && verboseLoggingArgExists)
            {
                VerboseLogging = null;
            }
            return(parserResult);
        }