示例#1
0
        private void AddCompileParameters()
        {
            _app.HelpOption("-h|--help");

            _outputOption = _app.Option("-o|--output <OUTPUT_DIR>", "Directory in which to place outputs", CommandOptionType.SingleValue);
            _buildBasePath = _app.Option("-b|--build-base-path <OUTPUT_DIR>", "Directory in which to place temporary outputs", CommandOptionType.SingleValue);
            _frameworkOption = _app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.SingleValue);
            _runtimeOption = _app.Option("-r|--runtime <RUNTIME_IDENTIFIER>", "Produce runtime-specific assets for the specified runtime", CommandOptionType.SingleValue);
            _configurationOption = _app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
            _versionSuffixOption = _app.Option("--version-suffix <VERSION_SUFFIX>", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue);
            _projectArgument = _app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");

            // HACK: Allow us to treat a project as though it was portable by ignoring the runtime-specific targets. This is temporary until RID inference is removed from NuGet
            _portableOption = _app.Option("--portable", "TEMPORARY: Enforces portable build/publish mode", CommandOptionType.NoValue);

            // Native Args
            _nativeOption = _app.Option("-n|--native", "Compiles source to native machine code.", CommandOptionType.NoValue);
            _archOption = _app.Option("-a|--arch <ARCH>", "The architecture for which to compile. x64 only currently supported.", CommandOptionType.SingleValue);
            _ilcArgsOption = _app.Option("--ilcarg <ARG>", "Command line option to be passed directly to ILCompiler.", CommandOptionType.MultipleValue);
            _ilcPathOption = _app.Option("--ilcpath <PATH>", "Path to the folder containing custom built ILCompiler.", CommandOptionType.SingleValue);
            _ilcSdkPathOption = _app.Option("--ilcsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
            _appDepSdkPathOption = _app.Option("--appdepsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
            _cppModeOption = _app.Option("--cpp", "Flag to do native compilation with C++ code generator.", CommandOptionType.NoValue);
            _cppCompilerFlagsOption = _app.Option("--cppcompilerflags <flags>", "Additional flags to be passed to the native compiler.", CommandOptionType.SingleValue);
        }
 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();
 }
示例#3
0
文件: Program.cs 项目: krwq/cli-1
 private static bool CheckArg(CommandOption argument)
 {
     if (!argument.HasValue())
     {
         Reporter.Error.WriteLine($"Missing required argument: {argument.LongName.Red().Bold()}");
         return false;
     }
     return true;
 }
        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";
        }
示例#5
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;
        }
示例#7
0
        private void AddCompileParameters()
        {
            _app.HelpOption("-h|--help");

            _outputOption = _app.Option("-o|--output <OUTPUT_DIR>", "Directory in which to place outputs", CommandOptionType.SingleValue);
            _intermediateOutputOption = _app.Option("-t|--temp-output <OUTPUT_DIR>", "Directory in which to place temporary outputs", CommandOptionType.SingleValue);
            _frameworkOption = _app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
            _configurationOption = _app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
            _noHostOption = _app.Option("--no-host", "Set this to skip publishing a runtime host when building for CoreCLR", CommandOptionType.NoValue);
            _projectArgument = _app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");

            // Native Args
            _nativeOption = _app.Option("-n|--native", "Compiles source to native machine code.", CommandOptionType.NoValue);
            _archOption = _app.Option("-a|--arch <ARCH>", "The architecture for which to compile. x64 only currently supported.", CommandOptionType.SingleValue);
            _ilcArgsOption = _app.Option("--ilcargs <ARGS>", "Command line arguments to be passed directly to ILCompiler.", CommandOptionType.SingleValue);
            _ilcPathOption = _app.Option("--ilcpath <PATH>", "Path to the folder containing custom built ILCompiler.", CommandOptionType.SingleValue);
            _ilcSdkPathOption = _app.Option("--ilcsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
            _appDepSdkPathOption = _app.Option("--appdepsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
            _cppModeOption = _app.Option("--cpp", "Flag to do native compilation with C++ code generator.", CommandOptionType.NoValue);
            _cppCompilerFlagsOption = _app.Option("--cppcompilerflags <flags>", "Additional flags to be passed to the native compiler.", CommandOptionType.SingleValue);
        }
        public void Options_UseCorrectName_Returns_CorrectValue(
            string propertyName,
            string expectedOptionTemplate,
            string expectedOptionDescription,
            int expectedCommandOptionType,
            string commandLineStringWithTheOption,
            object expectedValueWhenOptionIsPresent,
            object expectedValueWhenOptionIsNotPresent)
        {
            //Arrange
            var command = new CommandLineApplication();
            var property = typeof(TestClass).GetProperty(propertyName);
            var descriptor = new ParameterDescriptor(property);
            var expectedOption = new CommandOption(expectedOptionTemplate, (CommandOptionType)expectedCommandOptionType);

            //Act
            descriptor.AddCommandLineParameterTo(command);

            //Assert
            var actualOption = command.Options.First();
            Assert.Equal(expectedOption.LongName, actualOption.LongName);
            Assert.Equal(expectedOption.ShortName, actualOption.ShortName);
            Assert.Equal(expectedOption.OptionType, actualOption.OptionType);
            Assert.Equal(expectedOptionDescription, actualOption.Description);

            //Arrange
            command.Execute(new string[0] { });

            //Assert
            Assert.Equal(expectedValueWhenOptionIsNotPresent, descriptor.Value);

            //Arrange
            command.Execute(commandLineStringWithTheOption.Split(' '));

            //Assert
            Assert.Equal(expectedValueWhenOptionIsPresent, descriptor.Value);
        }
示例#9
0
        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;
            }
        }
示例#10
0
        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;
            }
        }
示例#11
0
 private void AddDotnetBaseParameters()
 {
     _app.HelpOption("-?|-h|--help");
     
     _configurationOption = _app.Option(
         "-c|--configuration <CONFIGURATION>",
         "Configuration under which to build",
         CommandOptionType.SingleValue);
     _outputOption = _app.Option(
         "-o|--output <OUTPUT_DIR>",
         "Directory in which to find the binaries to be run",
         CommandOptionType.SingleValue);
     _buildBasePath = _app.Option(
         "-b|--build-base-path <OUTPUT_DIR>",
         "Directory in which to find temporary outputs",
         CommandOptionType.SingleValue);
     _frameworkOption = _app.Option(
         "-f|--framework <FRAMEWORK>",
         "Looks for test binaries for a specific framework",
         CommandOptionType.SingleValue);
     _runtimeOption = _app.Option(
         "-r|--runtime <RUNTIME_IDENTIFIER>",
         "Look for test binaries for a for the specified runtime",
         CommandOptionType.SingleValue);  
     _projectPath = _app.Option(
         "-p|--project-path <PROJECT_JSON_PATH>",
         "Path to Project.json that contains the tool dependency",
         CommandOptionType.SingleValue);
     _command = _app.Argument(
         "<COMMAND>",
         "The command to execute.");
 }
示例#12
0
        private void AddDotnetTestParameters()
        {
            _app.HelpOption("-?|-h|--help");

            _parentProcessIdOption = _app.Option(
                "--parentProcessId",
                "Used by IDEs to specify their process ID. Test will exit if the parent process does.",
                CommandOptionType.SingleValue);
            _portOption = _app.Option(
                "--port",
                "Used by IDEs to specify a port number to listen for a connection.",
                CommandOptionType.SingleValue);
            _configurationOption = _app.Option(
                "-c|--configuration <CONFIGURATION>",
                "Configuration under which to build",
                CommandOptionType.SingleValue);
            _outputOption = _app.Option(
                "-o|--output <OUTPUT_DIR>",
                "Directory in which to find the binaries to be run",
                CommandOptionType.SingleValue);
            _buildBasePath = _app.Option(
                "-b|--build-base-path <OUTPUT_DIR>",
                "Directory in which to find temporary outputs",
                CommandOptionType.SingleValue);
            _frameworkOption = _app.Option(
                "-f|--framework <FRAMEWORK>",
                "Looks for test binaries for a specific framework",
                CommandOptionType.SingleValue);
            _runtimeOption = _app.Option(
                "-r|--runtime <RUNTIME_IDENTIFIER>",
                "Look for test binaries for a for the specified runtime",
                CommandOptionType.SingleValue);
            _noBuildOption =
                _app.Option("--no-build", "Do not build project before testing", CommandOptionType.NoValue);
            _projectPath = _app.Argument(
                "<PROJECT>",
                "The project to test, defaults to the current directory. Can be a path to a project.json or a project directory.");
        }