예제 #1
0
 private static string GetVersion(CommandOption versionOption)
 {
     if (versionOption.HasValue())
     {
         return versionOption.Value();
     }
     Console.Write("Please enter version to be inserted into project.json: ");
     return Console.ReadLine();
 }
예제 #2
0
        private static string GetFilePath(CommandOption filePathOption)
        {
            if (filePathOption.HasValue())
            {
                return filePathOption.Value();
            }
            Console.WriteLine("No project.json file path is provided. Assuming it is present in current directory.");

            return "project.json";
        }
예제 #3
0
        internal static LogLevel GetLogLevel(CommandOption verbosity)
        {
            LogLevel level;
            if (!Enum.TryParse(value: verbosity.Value(), ignoreCase: true, result: out level))
            {
                level = LogLevel.Information;
            }

            return level;
        }
        public static int ResolveProtocol(CommandOption clientProtocolCommand, int pluginProtocol)
        {
            int resolvedProtocol;
            if (clientProtocolCommand.HasValue())
            {
                resolvedProtocol = ResolveProtocol(clientProtocolCommand.Value(), pluginProtocol);
            }
            else
            {
                // Client protocol wasn't provided, use the plugin's protocol.
                resolvedProtocol = pluginProtocol;
            }

            return resolvedProtocol;
        }
예제 #5
0
파일: Program.cs 프로젝트: yonglehou/cli-1
        private static bool MonitorHostProcess(CommandOption host, ILogger logger)
        {
            if (!host.HasValue())
            {
                logger.LogError($"Option \"{host.LongName}\" is missing.");
                return false;
            }

            int hostPID;
            if (int.TryParse(host.Value(), out hostPID))
            {
                var hostProcess = Process.GetProcessById(hostPID);
                hostProcess.EnableRaisingEvents = true;
                hostProcess.Exited += (s, e) =>
                {
                    Process.GetCurrentProcess().Kill();
                };

                logger.LogDebug($"Server will exit when process {hostPID} exits.");
                return true;
            }
            else
            {
                logger.LogError($"Option \"{host.LongName}\" is not a valid Int32 value.");
                return false;
            }
        }
예제 #6
0
파일: Program.cs 프로젝트: yonglehou/cli-1
        private static int CheckPort(CommandOption port, ILogger logger)
        {
            if (!port.HasValue())
            {
                logger.LogError($"Option \"{port.LongName}\" is missing.");
            }

            int result;
            if (int.TryParse(port.Value(), out result))
            {
                return result;
            }
            else
            {
                logger.LogError($"Option \"{port.LongName}\" is not a valid Int32 value.");
                return -1;
            }
        }