@@ -357,7 +357,7 @@ using Internal;
357357 includeGeneratedArg,
358358 verbosityArg,
359359 binaryLogArg,
360- reportArg,
360+ reportArg
361361 ]
362362 ),
363363 new(
@@ -382,7 +382,7 @@ using Internal;
382382 includeGeneratedArg,
383383 verbosityArg,
384384 binaryLogArg,
385- reportArg,
385+ reportArg
386386 ]
387387 ),
388388 new(
@@ -406,7 +406,7 @@ using Internal;
406406 includeGeneratedArg,
407407 verbosityArg,
408408 binaryLogArg,
409- reportArg,
409+ reportArg
410410 ]
411411 ),
412412 new(
@@ -1616,16 +1616,15 @@ using Internal;
16161616 )
16171617 };
16181618
1619- foreach (var command in commands)
1619+ foreach (var (name, description, comments, strings, args, commandTypes, additionalArgs) in commands)
16201620 {
1621- var name = command.Name;
16221621 var commandArgs = new List<string>();
1623- foreach (var arg in command.CommandArgs )
1622+ foreach (var arg in strings )
16241623 {
16251624 if (arg.StartsWith("$"))
16261625 {
16271626 var curArg = arg.Substring(1);
1628- var notEmpty = command.Args .FirstOrDefault(i => i.PropertyName == curArg && i.IsCollection);
1627+ var notEmpty = args .FirstOrDefault(i => i.PropertyName == curArg && i.IsCollection);
16291628 if (notEmpty is not null && !string.IsNullOrWhiteSpace(notEmpty.PropertyName))
16301629 {
16311630 var compositeArg = $"new [] {{{string.Join(", ", commandArgs)}}}.Concat({curArg}).ToArray()";
@@ -1645,16 +1644,16 @@ using Internal;
16451644#>
16461645
16471646/// <summary>
1648- /// <#= command.Description #>
1647+ /// <#= description #>
16491648<#
1650- foreach (var comment in command.Comments )
1649+ foreach (var comment in comments )
16511650 {
16521651#>
16531652/// <#= comment #>
16541653<#
16551654 }
16561655
1657- var exampleFile = Path.Combine("..", "CSharpInteractive.Tests", "UsageScenarios", "Comments", $"{command.Name }Scenario.txt");
1656+ var exampleFile = Path.Combine("..", "CSharpInteractive.Tests", "UsageScenarios", "Comments", $"{name }Scenario.txt");
16581657 if (File.Exists(exampleFile))
16591658 {
16601659 var exampleLines = File.ReadAllLines(exampleFile);
@@ -1685,7 +1684,7 @@ using Internal;
16851684/// <param name="Args">Specifies the set of command line arguments to use when starting the tool.</param>
16861685/// <param name="Vars">Specifies the set of environment variables that apply to this process and its child processes.</param>
16871686<#
1688- foreach (var arg in command.Args .Where(i => i.IsCollection))
1687+ foreach (var arg in args .Where(i => i.IsCollection))
16891688 {
16901689#>
16911690/// <param name="<#= arg.PropertyName #>"><#= arg.Comments #></param>
@@ -1695,7 +1694,7 @@ using Internal;
16951694/// <param name="ExecutablePath">Overrides the tool executable path.</param>
16961695/// <param name="WorkingDirectory">Specifies the working directory for the tool to be started.</param>
16971696<#
1698- foreach (var arg in command.Args .Where(i => !i.IsCollection))
1697+ foreach (var arg in args .Where(i => !i.IsCollection))
16991698 {
17001699#>
17011700/// <param name="<#= arg.PropertyName #>"><#= arg.Comments #></param>
@@ -1704,13 +1703,13 @@ using Internal;
17041703#>
17051704/// <param name="ShortName">Specifies a short name for this operation.</param>
17061705[Target]
1707- public partial record <#= command.Name #>(
1706+ public partial record <#= name #>(
17081707 IEnumerable<string> Args,
17091708 IEnumerable<(string name, string value)> Vars,
17101709<#
1711- var initializer = string.Join(", ", new[] {"args", "[]"}.Concat(Enumerable.Repeat("[]", command.Args .Count(i => i.IsCollection))));
1712- var fullInitializer = string.Join(", ", new[] {"[]", "[]"}.Concat(Enumerable.Repeat("[]", command.Args .Count(i => i.IsCollection))));
1713- foreach (var arg in command.Args )
1710+ var initializer = string.Join(", ", new[] {"args", "[]"}.Concat(Enumerable.Repeat("[]", args .Count(i => i.IsCollection))));
1711+ var fullInitializer = string.Join(", ", new[] {"[]", "[]"}.Concat(Enumerable.Repeat("[]", args .Count(i => i.IsCollection))));
1712+ foreach (var arg in args )
17141713 {
17151714 var type = arg.Type;
17161715 var defaultValue = "";
@@ -1728,7 +1727,7 @@ public partial record <#= command.Name #>(
17281727 {
17291728 if (!arg.IsCollection)
17301729 {
1731- defaultValue = " = default ";
1730+ defaultValue = " = null ";
17321731 }
17331732 }
17341733 }
@@ -1763,7 +1762,7 @@ public partial record <#= command.Name #>(
17631762 {
17641763 if (host == null) throw new ArgumentNullException(nameof(host));
17651764<#
1766- if ((command.CommandTypes & CommandTypes.RequiresSettings) == CommandTypes.RequiresSettings)
1765+ if ((commandTypes & CommandTypes.RequiresSettings) == CommandTypes.RequiresSettings)
17671766 {
17681767#>
17691768 var components = host.GetService<HostComponents>();
@@ -1777,12 +1776,12 @@ public partial record <#= command.Name #>(
17771776 .WithWorkingDirectory(WorkingDirectory)
17781777 .WithVars(Vars.ToArray())
17791778<#
1780- foreach (var arg in command.CommandArgs )
1779+ foreach (var arg in strings )
17811780 {
17821781 if (arg.StartsWith("$"))
17831782 {
17841783 var notEmptyArg = arg.Substring(1);
1785- var notEmpty = command.Args .FirstOrDefault(i => i.PropertyName == notEmptyArg && i.IsCollection);
1784+ var notEmpty = args .FirstOrDefault(i => i.PropertyName == notEmptyArg && i.IsCollection);
17861785 if (notEmpty is not null && !string.IsNullOrWhiteSpace(notEmpty.PropertyName))
17871786 {
17881787 notEmptyArg = $"{notEmptyArg}.ToArray()";
@@ -1804,35 +1803,35 @@ public partial record <#= command.Name #>(
18041803 }
18051804#>
18061805<#
1807- if ((command.CommandTypes & CommandTypes.Build) == CommandTypes.Build)
1806+ if ((commandTypes & CommandTypes.Build) == CommandTypes.Build)
18081807 {
18091808#>
18101809 .AddMSBuildLoggers(host, Verbosity)
18111810<#
18121811 }
18131812
1814- if ((command.CommandTypes & CommandTypes.Test) == CommandTypes.Test)
1813+ if ((commandTypes & CommandTypes.Test) == CommandTypes.Test)
18151814 {
18161815#>
18171816 .AddTestLoggers(host, Loggers)
18181817<#
18191818 }
18201819
1821- foreach (var additionalArg in command.AdditionalArgs )
1820+ foreach (var additionalArg in additionalArgs )
18221821 {
18231822#>
18241823 .AddArgs("<#= additionalArg #>")
18251824<#
18261825 }
18271826
1828- foreach (var arg in command.Args .Where(i => !i.IsProject).Where(i => i.IsCollection && i.ArgName != "--property"))
1827+ foreach (var arg in args .Where(i => !i.IsProject).Where(i => i.IsCollection && i.ArgName != "--property"))
18291828 {
18301829#>
18311830 .AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.Separator #>"))
18321831<#
18331832 }
18341833
1835- foreach (var arg in command.Args .Where(i => !i.IsProject).Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && !i.Type.StartsWith("bool") && !i.IsCollection))
1834+ foreach (var arg in args .Where(i => !i.IsProject).Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && !i.Type.StartsWith("bool") && !i.IsCollection))
18361835 {
18371836 if (string.IsNullOrWhiteSpace(arg.AddArgOverride))
18381837 {
@@ -1848,7 +1847,7 @@ public partial record <#= command.Name #>(
18481847 }
18491848 }
18501849
1851- var boolArgs = command.Args .Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.Type.StartsWith("bool")).ToArray();
1850+ var boolArgs = args .Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.Type.StartsWith("bool")).ToArray();
18521851#><#= boolArgs.Length > 0 ? " .AddBooleanArgs(\n": ""#><#
18531852 for (var i = 0; i < boolArgs.Length; i++)
18541853 {
@@ -1858,7 +1857,7 @@ public partial record <#= command.Name #>(
18581857<#
18591858 }
18601859#><#= boolArgs.Length > 0 ? " )\n": ""#><#
1861- foreach (var arg in command.Args .Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.IsCollection && i.ArgName == "--property").ToArray())
1860+ foreach (var arg in args .Where(i => !string.IsNullOrWhiteSpace(i.ArgName) && i.IsCollection && i.ArgName == "--property").ToArray())
18621861 {
18631862#>
18641863 .AddProps("--property", <#= arg.PropertyName #>.ToArray())
@@ -1869,7 +1868,7 @@ public partial record <#= command.Name #>(
18691868 }
18701869
18711870 /// <inheritdoc/>
1872- public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("<#= command.Description #>", ShortName, <#= string.Join(", ", commandArgs) #>);
1871+ public override string ToString() => (ExecutablePath == string.Empty ? "dotnet" : Path.GetFileNameWithoutExtension(ExecutablePath)).GetShortName("<#= description #>", ShortName, <#= string.Join(", ", commandArgs) #>);
18731872}
18741873<#
18751874 }
0 commit comments