dotnet-installer/src/dotnet/commands/dotnet-restore/RestoreCommandParser.cs

65 lines
3.2 KiB
C#
Raw Normal View History

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
2017-03-10 13:36:18 -08:00
using LocalizableStrings = Microsoft.DotNet.Tools.Restore.LocalizableStrings;
namespace Microsoft.DotNet.Cli
{
internal static class RestoreCommandParser
{
public static Command Restore() =>
Create.Command(
"restore",
2017-03-10 13:36:18 -08:00
LocalizableStrings.AppFullName,
2017-03-10 17:11:19 -08:00
Accept.ZeroOrMoreArguments(),
2017-03-06 20:53:26 -08:00
CommonOptions.HelpOption(),
Create.Option(
"-s|--source",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdSourceOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.OneOrMoreArguments()
2017-03-10 13:36:18 -08:00
.With(name: LocalizableStrings.CmdSourceOption)
2017-03-06 20:53:26 -08:00
.ForwardAs(o => $"/p:RestoreSources={string.Join("%3B", o.Arguments)}")),
Create.Option(
"-r|--runtime",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdRuntimeOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.OneOrMoreArguments()
2017-03-06 20:53:26 -08:00
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
2017-03-10 13:36:18 -08:00
.With(name: LocalizableStrings.CmdRuntimeOption)
2017-03-06 20:53:26 -08:00
.ForwardAs(o => $"/p:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
Create.Option(
"--packages",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdPackagesOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.ExactlyOneArgument()
2017-03-10 13:36:18 -08:00
.With(name: LocalizableStrings.CmdPackagesOption)
.ForwardAs(o => $"/p:RestorePackagesPath={o.Arguments.Single()}")),
2017-03-06 20:53:26 -08:00
Create.Option(
"--disable-parallel",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdDisableParallelOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.NoArguments()
2017-03-06 20:53:26 -08:00
.ForwardAs("/p:RestoreDisableParallel=true")),
Create.Option(
"--configfile",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdConfigFileOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.ExactlyOneArgument()
2017-03-10 13:36:18 -08:00
.With(name: LocalizableStrings.CmdConfigFileOption)
.ForwardAs(o => $"/p:RestoreConfigFile={o.Arguments.Single()}")),
2017-03-06 20:53:26 -08:00
Create.Option(
"--no-cache",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdNoCacheOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.NoArguments()
2017-03-06 20:53:26 -08:00
.ForwardAs("/p:RestoreNoCache=true")),
Create.Option(
"--ignore-failed-sources",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.NoArguments()
2017-03-06 20:53:26 -08:00
.ForwardAs("/p:RestoreIgnoreFailedSources=true")),
Create.Option(
"--no-dependencies",
2017-03-10 13:36:18 -08:00
LocalizableStrings.CmdNoDependenciesOptionDescription,
2017-03-10 17:11:19 -08:00
Accept.NoArguments()
2017-03-06 20:53:26 -08:00
.ForwardAs("/p:RestoreRecursive=false")),
CommonOptions.VerbosityOption());
}
}