Beispiel #1
0
        public static RunCommand FromArgs(string[] args)
        {
            var parseResult = Parser.Instance.ParseFrom("dotnet run", args);

            if (parseResult.HasOption("--help"))
            {
                parseResult.ShowHelp();
                throw new HelpException(string.Empty);
            }

            var project = parseResult.ValueForOption(RunCommandParser.ProjectOption);

            if (parseResult.UsingRunCommandShorthandProjectOption())
            {
                Console.WriteLine(LocalizableStrings.RunCommandProjectAbbreviationDeprecated.Yellow());
                project = parseResult.GetRunCommandShorthandProjectValues().FirstOrDefault();
            }

            var command = new RunCommand(
                configuration: parseResult.ValueForOption <string>(RunCommandParser.ConfigurationOption),
                framework: parseResult.ValueForOption <string>(RunCommandParser.FrameworkOption),
                runtime: parseResult.GetCommandLineRuntimeIdentifier(),
                noBuild: parseResult.HasOption(RunCommandParser.NoBuildOption),
                project: project,
                launchProfile: parseResult.ValueForOption <string>(RunCommandParser.LaunchProfileOption),
                noLaunchProfile: parseResult.HasOption(RunCommandParser.NoLaunchProfileOption),
                noRestore: parseResult.HasOption(RunCommandParser.NoRestoreOption) || parseResult.HasOption(RunCommandParser.NoBuildOption),
                interactive: parseResult.HasOption(RunCommandParser.InteractiveOption),
                restoreArgs: parseResult.OptionValuesToBeForwarded(RunCommandParser.GetCommand()),
                args: (parseResult.UnparsedTokens ?? Array.Empty <string>()).Concat(parseResult.UnmatchedTokens ?? Array.Empty <string>())
                );

            return(command);
        }
Beispiel #2
0
        public static RunCommand FromArgs(string[] args)
        {
            var parseResult = Parser.Instance.ParseFrom("dotnet run", args);

            if (parseResult.HasOption("--help"))
            {
                parseResult.ShowHelp();
                throw new HelpException(string.Empty);
            }

            var command = new RunCommand(
                configuration: parseResult.ValueForOption <string>(RunCommandParser.ConfigurationOption),
                framework: parseResult.ValueForOption <string>(RunCommandParser.FrameworkOption),
                runtime: parseResult.ValueForOption <string>(RunCommandParser.RuntimeOption),
                noBuild: parseResult.HasOption(RunCommandParser.NoBuildOption),
                project: parseResult.ValueForOption <string>(RunCommandParser.ProjectOption),
                launchProfile: parseResult.ValueForOption <string>(RunCommandParser.LaunchProfileOption),
                noLaunchProfile: parseResult.HasOption(RunCommandParser.NoLaunchProfileOption),
                noRestore: parseResult.HasOption(RunCommandParser.NoRestoreOption) || parseResult.HasOption(RunCommandParser.NoBuildOption),
                interactive: parseResult.HasOption(RunCommandParser.InteractiveOption),
                restoreArgs: parseResult.OptionValuesToBeForwarded(RunCommandParser.GetCommand()),
                args: (parseResult.UnparsedTokens ?? Array.Empty <string>()).Concat(parseResult.UnmatchedTokens ?? Array.Empty <string>())
                );

            return(command);
        }
Beispiel #3
0
        public static RunCommand FromParseResult(ParseResult parseResult)
        {
            var project = parseResult.GetValueForOption(RunCommandParser.ProjectOption);

            if (parseResult.UsingRunCommandShorthandProjectOption())
            {
                Reporter.Output.WriteLine(LocalizableStrings.RunCommandProjectAbbreviationDeprecated.Yellow());
                project = parseResult.GetRunCommandShorthandProjectValues().FirstOrDefault();
            }

            var command = new RunCommand(
                configuration: parseResult.GetValueForOption(RunCommandParser.ConfigurationOption),
                framework: parseResult.GetValueForOption(RunCommandParser.FrameworkOption),
                runtime: parseResult.GetCommandLineRuntimeIdentifier(),
                noBuild: parseResult.HasOption(RunCommandParser.NoBuildOption),
                project: project,
                launchProfile: parseResult.GetValueForOption(RunCommandParser.LaunchProfileOption),
                noLaunchProfile: parseResult.HasOption(RunCommandParser.NoLaunchProfileOption),
                noRestore: parseResult.HasOption(RunCommandParser.NoRestoreOption) || parseResult.HasOption(RunCommandParser.NoBuildOption),
                interactive: parseResult.HasOption(RunCommandParser.InteractiveOption),
                restoreArgs: parseResult.OptionValuesToBeForwarded(RunCommandParser.GetCommand()),
                args: (parseResult.UnparsedTokens ?? Array.Empty <string>()).Concat(parseResult.UnmatchedTokens ?? Array.Empty <string>())
                );

            return(command);
        }