Skip to content

Commit

Permalink
Use DotNet command template
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Oct 16, 2024
1 parent 455c6b6 commit 779a73f
Show file tree
Hide file tree
Showing 17 changed files with 924 additions and 763 deletions.
8 changes: 4 additions & 4 deletions CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
<DependentUpon>CommandLines.tt</DependentUpon>
</Compile>

<None Update="SimpleDotNetCommands.tt">
<LastGenOutput>SimpleDotNetCommands.cs</LastGenOutput>
<None Update="DotNetCommands.tt">
<LastGenOutput>DotNetCommands.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
</None>

<Compile Update="SimpleDotNetCommands.cs">
<Compile Update="DotNetCommands.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>SimpleDotNetCommands.tt</DependentUpon>
<DependentUpon>DotNetCommands.tt</DependentUpon>
</Compile>
</ItemGroup>

Expand Down
68 changes: 68 additions & 0 deletions CSharpInteractive.HostApi/CommandLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,74 @@ public partial record DotNetNuGetWhy: ICommandLine
public static DotNetNuGetWhy operator -(DotNetNuGetWhy command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars);
}

[ExcludeFromCodeCoverage]
public partial record DotNetNuConfigGet: ICommandLine
{
/// <summary>
/// Appends an argument.
/// </summary>
/// <param name="command">The command to which an argument will be added.</param>
/// <param name="arg">Argument to add.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator +(DotNetNuConfigGet command, string arg) => command.AddArgs(arg);

/// <summary>
/// Removes an argument by its name.
/// </summary>
/// <param name="command">The command to which an argument will be removed.</param>
/// <param name="arg">Argument to remove.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator -(DotNetNuConfigGet command, string arg) => command.RemoveArgs(arg);

/// <summary>
/// Appends arguments.
/// </summary>
/// <param name="command">The command to which arguments will be added.</param>
/// <param name="args">Arguments to add.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator +(DotNetNuConfigGet command, IEnumerable<string> args) => command.AddArgs(args);

/// <summary>
/// Removes arguments by their name.
/// </summary>
/// <param name="command">The command to which arguments will be removed.</param>
/// <param name="args">Arguments to remove.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator -(DotNetNuConfigGet command, IEnumerable<string> args) => command.RemoveArgs(args);

/// <summary>
/// Appends an environment variable.
/// </summary>
/// <param name="command">The command to which an environment variable will be added.</param>
/// <param name="var">Environment variable to add.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator +(DotNetNuConfigGet command, (string name, string value) var) => command.AddVars(var);

/// <summary>
/// Removes environment variable by its name and value.
/// </summary>
/// <param name="command">The command to which an environment variable will be removed.</param>
/// <param name="var">Environment variable to remove.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator -(DotNetNuConfigGet command, (string name, string value) var) => command.RemoveVars(var);

/// <summary>
/// Appends environment variables.
/// </summary>
/// <param name="command">The command to which environment variables will be added.</param>
/// <param name="vars">Environment variables to add.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator +(DotNetNuConfigGet command, IEnumerable<(string name, string value)> vars) => command.AddVars(vars);

/// <summary>
/// Removes environment variables by their name and value.
/// </summary>
/// <param name="command">The command to which environment variables will be removed.</param>
/// <param name="vars">environment variables to remove.</param>
/// <returns>Returns a new command with the corresponding changes.</returns>
public static DotNetNuConfigGet operator -(DotNetNuConfigGet command, IEnumerable<(string name, string value)> vars) => command.RemoveVars(vars);
}

[ExcludeFromCodeCoverage]
public partial record DotNetPack: ICommandLine
{
Expand Down
6 changes: 2 additions & 4 deletions CSharpInteractive.HostApi/CommandLines.tt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Text" #>
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming
namespace HostApi;

<#
Expand Down Expand Up @@ -51,6 +48,7 @@ namespace HostApi;
"DotNetNuGetTrustSource",
"DotNetNuGetSign",
"DotNetNuGetWhy",
"DotNetNuConfigGet",
"DotNetPack",
"DotNetPublish",
"DotNetRestore",
Expand Down
3 changes: 2 additions & 1 deletion CSharpInteractive.HostApi/DotNetBuildServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum DotNetBuildServer

internal static class DotNetBuildServerExtensions
{
public static string[] ToArgs(this IEnumerable<DotNetBuildServer> servers, string name) =>
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
public static string[] ToArgs(this IEnumerable<DotNetBuildServer> servers, string name, string collectionSeparator) =>
servers.Select(server => server switch
{
DotNetBuildServer.MSBuild => "--msbuild",
Expand Down
Loading

0 comments on commit 779a73f

Please sign in to comment.