Skip to content

Commit af4967d

Browse files
committed
Merged PR 36667: Merge public to internal
This includes the nuget package search change, a merge resolution, and a revert of a bad merge.
1 parent a96621e commit af4967d

21 files changed

+1606
-0
lines changed

src/Cli/dotnet/Parser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static class Parser
3838
NewCommandParser.GetCommand(),
3939
NuGetCommandParser.GetCommand(),
4040
PackCommandParser.GetCommand(),
41+
PackageCommandParser.GetCommand(),
4142
ParseCommandParser.GetCommand(),
4243
PublishCommandParser.GetCommand(),
4344
RemoveCommandParser.GetCommand(),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CommandLine;
5+
6+
namespace Microsoft.DotNet.Cli
7+
{
8+
internal class PackageCommandParser
9+
{
10+
private const string DocsLink = "https://aka.ms/dotnet-package";
11+
12+
public static CliCommand GetCommand()
13+
{
14+
CliCommand command = new DocumentedCommand("package", DocsLink);
15+
command.SetAction((parseResult) => parseResult.HandleMissingCommand());
16+
command.Subcommands.Add(PackageSearchCommandParser.GetCommand());
17+
18+
return command;
19+
}
20+
}
21+
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
<data name="CommandDescription" xml:space="preserve">
121+
<value>Searches one or more package sources for packages that match a search term. If no sources are specified, all sources defined in the NuGet.Config are used.</value>
122+
</data>
123+
<data name="ConfigFileArgumentName" xml:space="preserve">
124+
<value>ConfigFile</value>
125+
</data>
126+
<data name="ConfigFileDescription" xml:space="preserve">
127+
<value>The NuGet configuration file. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see https://docs.microsoft.com/nuget/consume-packages/configuring-nuget-behavior</value>
128+
</data>
129+
<data name="ExactMatchDescription" xml:space="preserve">
130+
<value>Require that the search term exactly match the name of the package. Causes `--take` and `--skip` options to be ignored.</value>
131+
</data>
132+
<data name="FormatArgumentName" xml:space="preserve">
133+
<value>Format</value>
134+
</data>
135+
<data name="FormatDescription" xml:space="preserve">
136+
<value>Format the output accordingly. Either `table`, or `json`. The default value is `table`.</value>
137+
</data>
138+
<data name="InteractiveDescription" xml:space="preserve">
139+
<value>Stop and wait for user input or action (for example to complete authentication).</value>
140+
</data>
141+
<data name="PrereleaseDescription" xml:space="preserve">
142+
<value>Include prerelease packages.</value>
143+
</data>
144+
<data name="SearchTermArgumentName" xml:space="preserve">
145+
<value>SearchTerm</value>
146+
</data>
147+
<data name="SearchTermDescription" xml:space="preserve">
148+
<value>Search term to filter package names, descriptions, and tags. Used as a literal value. Example: `dotnet package search some.package`. See also `--exact-match`.</value>
149+
</data>
150+
<data name="SkipArgumentName" xml:space="preserve">
151+
<value>Skip</value>
152+
</data>
153+
<data name="SkipDescription" xml:space="preserve">
154+
<value>Number of results to skip, to allow pagination. Default 0.</value>
155+
</data>
156+
<data name="SourceArgumentName" xml:space="preserve">
157+
<value>Source</value>
158+
</data>
159+
<data name="SourceDescription" xml:space="preserve">
160+
<value>The package source to search. You can pass multiple `--source` options to search multiple package sources. Example: `--source https://api.nuget.org/v3/index.json`.</value>
161+
</data>
162+
<data name="TakeArgumentName" xml:space="preserve">
163+
<value>Take</value>
164+
</data>
165+
<data name="TakeDescription" xml:space="preserve">
166+
<value>Number of results to return. Default 20.</value>
167+
</data>
168+
<data name="VerbosityArgumentName" xml:space="preserve">
169+
<value>Verbosity</value>
170+
</data>
171+
<data name="VerbosityDescription" xml:space="preserve">
172+
<value>Display this amount of details in the output: `normal`, `minimal`, `detailed`. The default is `normal`</value>
173+
</data>
174+
</root>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.DotNet.Tools.NuGet;
5+
using System.CommandLine;
6+
7+
namespace Microsoft.DotNet.Cli
8+
{
9+
internal class PackageSearchCommand : CommandBase
10+
{
11+
public PackageSearchCommand(ParseResult parseResult) : base(parseResult) { }
12+
13+
public override int Execute()
14+
{
15+
var args = new List<string>
16+
{
17+
"package",
18+
"search"
19+
};
20+
21+
var searchArgument = _parseResult.GetValue(PackageSearchCommandParser.SearchTermArgument);
22+
if (searchArgument != null)
23+
{
24+
args.Add(searchArgument);
25+
}
26+
27+
args.AddRange(_parseResult.OptionValuesToBeForwarded(PackageSearchCommandParser.GetCommand()));
28+
return NuGetCommand.Run(args.ToArray());
29+
}
30+
}
31+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CommandLine;
5+
using LocalizableStrings = Microsoft.DotNet.Tools.Package.Search.LocalizableStrings;
6+
7+
namespace Microsoft.DotNet.Cli
8+
{
9+
internal static class PackageSearchCommandParser
10+
{
11+
public static readonly CliArgument<string> SearchTermArgument = new CliArgument<string>("SearchTerm")
12+
{
13+
HelpName = LocalizableStrings.SearchTermArgumentName,
14+
Description = LocalizableStrings.SearchTermDescription,
15+
Arity = ArgumentArity.ZeroOrOne
16+
};
17+
18+
public static readonly CliOption Sources = new ForwardedOption<IEnumerable<string>>("--source")
19+
{
20+
Description = LocalizableStrings.SourceDescription,
21+
HelpName = LocalizableStrings.SourceArgumentName
22+
}.ForwardAsManyArgumentsEachPrefixedByOption("--source")
23+
.AllowSingleArgPerToken();
24+
25+
public static readonly CliOption<string> Take = new ForwardedOption<string>("--take")
26+
{
27+
Description = LocalizableStrings.TakeDescription,
28+
HelpName = LocalizableStrings.TakeArgumentName
29+
}.ForwardAsSingle(o => $"--take:{o}");
30+
31+
public static readonly CliOption<string> Skip = new ForwardedOption<string>("--skip")
32+
{
33+
Description = LocalizableStrings.SkipDescription,
34+
HelpName = LocalizableStrings.SkipArgumentName
35+
}.ForwardAsSingle(o => $"--skip:{o}");
36+
37+
public static readonly CliOption<bool> ExactMatch = new ForwardedOption<bool>("--exact-match")
38+
{
39+
Description = LocalizableStrings.ExactMatchDescription
40+
}.ForwardAs("--exact-match");
41+
42+
public static readonly CliOption<bool> Interactive = new ForwardedOption<bool>("--interactive")
43+
{
44+
Description = LocalizableStrings.InteractiveDescription
45+
}.ForwardAs("--interactive");
46+
47+
public static readonly CliOption<bool> Prerelease = new ForwardedOption<bool>("--prerelease")
48+
{
49+
Description = LocalizableStrings.PrereleaseDescription
50+
}.ForwardAs("--prerelease");
51+
52+
public static readonly CliOption<string> ConfigFile = new ForwardedOption<string>("--configfile")
53+
{
54+
Description = LocalizableStrings.ConfigFileDescription,
55+
HelpName = LocalizableStrings.ConfigFileArgumentName
56+
}.ForwardAsSingle(o => $"--configfile:{o}");
57+
58+
public static readonly CliOption<string> Format = new ForwardedOption<string>("--format")
59+
{
60+
Description = LocalizableStrings.FormatDescription,
61+
HelpName = LocalizableStrings.FormatArgumentName
62+
}.ForwardAsSingle(o => $"--format:{o}");
63+
64+
public static readonly CliOption<string> Verbosity = new ForwardedOption<string>("--verbosity")
65+
{
66+
Description = LocalizableStrings.VerbosityDescription,
67+
HelpName = LocalizableStrings.VerbosityArgumentName
68+
}.ForwardAsSingle(o => $"--verbosity:{o}");
69+
70+
private static readonly CliCommand Command = ConstructCommand();
71+
72+
public static CliCommand GetCommand()
73+
{
74+
return Command;
75+
}
76+
77+
private static CliCommand ConstructCommand()
78+
{
79+
CliCommand searchCommand = new("search", LocalizableStrings.CommandDescription);
80+
81+
searchCommand.Arguments.Add(SearchTermArgument);
82+
searchCommand.Options.Add(Sources);
83+
searchCommand.Options.Add(Take);
84+
searchCommand.Options.Add(Skip);
85+
searchCommand.Options.Add(ExactMatch);
86+
searchCommand.Options.Add(Interactive);
87+
searchCommand.Options.Add(Prerelease);
88+
searchCommand.Options.Add(ConfigFile);
89+
searchCommand.Options.Add(Format);
90+
searchCommand.Options.Add(Verbosity);
91+
92+
searchCommand.SetAction((parseResult) => {
93+
var command = new PackageSearchCommand(parseResult);
94+
int exitCode = command.Execute();
95+
96+
if (exitCode == 1)
97+
{
98+
parseResult.ShowHelp();
99+
}
100+
});
101+
102+
return searchCommand;
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)