@autorest/powershell 3.0.477 → 3.0.480
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +5 -5
- package/package.json +1 -1
- package/resources/assets/create-model-cmdlets.ps1 +4 -2
- package/resources/psruntime/BuildTime/Models/PsHelpMarkdownOutputs.cs +32 -10
- package/resources/psruntime/BuildTime/Models/PsHelpTypes.cs +3 -0
- package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +13 -6
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"powershell/models/model-extensions.ts": "9394418ac00c3e8829760432053c087642e4222d",
|
|
72
72
|
"powershell/module/module-class.ts": "863c9fd1d0243cbe8ea6858932945f00221dd5b1",
|
|
73
73
|
"powershell/module/module-namespace.ts": "f6afc90087e8d733f0323b0de8ba41d923955732",
|
|
74
|
-
"powershell/package.json": "
|
|
74
|
+
"powershell/package.json": "d5d3730451fd87f90d0590c1794597d4ca7885eb",
|
|
75
75
|
"powershell/plugins/add-azure-completers-v2.ts": "557ce4326318c82f91445490a162f20fa029fed3",
|
|
76
76
|
"powershell/plugins/create-commands-v2.ts": "fc36205364fa4d2aa9c0fc655dcd9a7f6f1d4063",
|
|
77
77
|
"powershell/plugins/cs-namer-v2.ts": "e294a2f5ac3db421d030a3bba8343a3d4a9ea6ab",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"powershell/readme.md": "fe572b3ccddf3809363aff0d673c01c04509a757",
|
|
87
87
|
"powershell/resources/assets/build-module.ps1": "64761cf5324d6ccc32bbb908c53eecabe81acbd0",
|
|
88
88
|
"powershell/resources/assets/check-dependencies.ps1": "3f0a7cf45f38f941138322906d14b4bfcf684ad5",
|
|
89
|
-
"powershell/resources/assets/create-model-cmdlets.ps1": "
|
|
89
|
+
"powershell/resources/assets/create-model-cmdlets.ps1": "dd3f8b745a2a6fb5b1bbd115ab64b0d0fdc725aa",
|
|
90
90
|
"powershell/resources/assets/custom/README.md": "b802db3b38ec4c5db299a62b98509315208e7a5f",
|
|
91
91
|
"powershell/resources/assets/docs/README.md": "63035d1e0c808d2ba3bed2f0a5ffe7fc48ecc377",
|
|
92
92
|
"powershell/resources/assets/examples/README.md": "a0ad7c4631b6944a22edd0c2d23fe0bc66365ac7",
|
|
@@ -212,9 +212,9 @@
|
|
|
212
212
|
"powershell/resources/psruntime/BuildTime/CollectionExtensions.cs": "c9e0c8a57c8d5affe7fa1b0da3a9bc1212609dc0",
|
|
213
213
|
"powershell/resources/psruntime/BuildTime/MarkdownRenderer.cs": "f96fa52f7e9d02ed1a3f3f748d9da5ec0ab2099b",
|
|
214
214
|
"powershell/resources/psruntime/BuildTime/Models/PsFormatTypes.cs": "40fffed4474e6e4c2d7a057370a2aa036001b09a",
|
|
215
|
-
"powershell/resources/psruntime/BuildTime/Models/PsHelpMarkdownOutputs.cs": "
|
|
216
|
-
"powershell/resources/psruntime/BuildTime/Models/PsHelpTypes.cs": "
|
|
217
|
-
"powershell/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs": "
|
|
215
|
+
"powershell/resources/psruntime/BuildTime/Models/PsHelpMarkdownOutputs.cs": "056be554968d76667c0659d169f674ef5dbb74ed",
|
|
216
|
+
"powershell/resources/psruntime/BuildTime/Models/PsHelpTypes.cs": "34d832146757eab7d8e1bd3feba5d411577f388a",
|
|
217
|
+
"powershell/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs": "04c8ab64ab6269ee2cf7193494425d869bb6b94d",
|
|
218
218
|
"powershell/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs": "3d75461091c4847bcc89b7ada96179dd4d4ba10a",
|
|
219
219
|
"powershell/resources/psruntime/BuildTime/Models/PsProxyTypes.cs": "d12d48f864b20004aa129623ebd032e8f16cdee2",
|
|
220
220
|
"powershell/resources/psruntime/BuildTime/PsAttributes.cs": "db38af61484cec976c6833987625e191cfea5d5d",
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ function CreateModelCmdlet {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
$ModelCsPath = Join-Path (Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.apiFolder)}') 'Models'
|
|
15
|
-
$ModuleName = '${$project.
|
|
15
|
+
$ModuleName = '${$project.subjectPrefix}'
|
|
16
16
|
$OutputDir = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.modelCmdletFolder)}'
|
|
17
17
|
$null = New-Item -ItemType Directory -Force -Path $OutputDir
|
|
18
18
|
|
|
@@ -104,7 +104,9 @@ function CreateModelCmdlet {
|
|
|
104
104
|
# check whether completer is needed
|
|
105
105
|
$completer = '';
|
|
106
106
|
if($Type.Split('.').Split('.')[-2] -eq 'Support') {
|
|
107
|
-
|
|
107
|
+
# If Type is an array, need to strip []
|
|
108
|
+
$strippedType = $Type.Replace('[]', '')
|
|
109
|
+
$completer += "`n [ArgumentCompleter([${strippedType}])]"
|
|
108
110
|
}
|
|
109
111
|
$ParameterDefineScript = "
|
|
110
112
|
[Parameter($ParameterDefineProperty)]${completer}
|
|
@@ -52,6 +52,17 @@ schema: {HelpInfo.Schema.ToString(3)}
|
|
|
52
52
|
|
|
53
53
|
internal class HelpExampleOutput
|
|
54
54
|
{
|
|
55
|
+
private string ExampleTemplate =
|
|
56
|
+
"{0}{1}" + Environment.NewLine +
|
|
57
|
+
"{2}" + Environment.NewLine + "{3}" + Environment.NewLine + "{4}" + Environment.NewLine + Environment.NewLine +
|
|
58
|
+
"{5}" + Environment.NewLine + Environment.NewLine;
|
|
59
|
+
|
|
60
|
+
private string ExampleTemplateWithOutput =
|
|
61
|
+
"{0}{1}" + Environment.NewLine +
|
|
62
|
+
"{2}" + Environment.NewLine + "{3}" + Environment.NewLine + "{4}" + Environment.NewLine + Environment.NewLine +
|
|
63
|
+
"{5}" + Environment.NewLine + "{6}" + Environment.NewLine + "{7}" + Environment.NewLine + Environment.NewLine +
|
|
64
|
+
"{8}" + Environment.NewLine + Environment.NewLine;
|
|
65
|
+
|
|
55
66
|
public MarkdownExampleHelpInfo ExampleInfo { get; }
|
|
56
67
|
|
|
57
68
|
public HelpExampleOutput(MarkdownExampleHelpInfo exampleInfo)
|
|
@@ -59,17 +70,26 @@ schema: {HelpInfo.Schema.ToString(3)}
|
|
|
59
70
|
ExampleInfo = exampleInfo;
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
public override string ToString()
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
public override string ToString()
|
|
74
|
+
{
|
|
75
|
+
if (string.IsNullOrEmpty(ExampleInfo.Output))
|
|
76
|
+
{
|
|
77
|
+
return string.Format(ExampleTemplate,
|
|
78
|
+
ExampleNameHeader, ExampleInfo.Name,
|
|
79
|
+
ExampleCodeHeader, ExampleInfo.Code, ExampleCodeFooter,
|
|
80
|
+
ExampleInfo.Description.ToDescriptionFormat());
|
|
81
|
+
}
|
|
82
|
+
else
|
|
83
|
+
{
|
|
84
|
+
return string.Format(ExampleTemplateWithOutput,
|
|
85
|
+
ExampleNameHeader, ExampleInfo.Name,
|
|
86
|
+
ExampleCodeHeader, ExampleInfo.Code, ExampleCodeFooter,
|
|
87
|
+
ExampleOutputHeader, ExampleInfo.Output, ExampleOutputFooter,
|
|
88
|
+
ExampleInfo.Description.ToDescriptionFormat()); ;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
70
91
|
}
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
|
|
73
93
|
internal class HelpParameterOutput
|
|
74
94
|
{
|
|
75
95
|
public MarkdownParameterHelpInfo ParameterInfo { get; }
|
|
@@ -161,6 +181,8 @@ Locale: en-US
|
|
|
161
181
|
public const string ExampleNameHeader = "### ";
|
|
162
182
|
public const string ExampleCodeHeader = "```powershell";
|
|
163
183
|
public const string ExampleCodeFooter = "```";
|
|
184
|
+
public const string ExampleOutputHeader = "```output";
|
|
185
|
+
public const string ExampleOutputFooter = "```";
|
|
164
186
|
|
|
165
187
|
public static HelpMetadataOutput ToHelpMetadataOutput(this MarkdownHelpInfo helpInfo) => new HelpMetadataOutput(helpInfo);
|
|
166
188
|
|
|
@@ -109,18 +109,21 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
109
109
|
{
|
|
110
110
|
public string Title { get; }
|
|
111
111
|
public string Code { get; }
|
|
112
|
+
public string Output { get; }
|
|
112
113
|
public string Remarks { get; }
|
|
113
114
|
|
|
114
115
|
public PsHelpExampleInfo(PSObject exampleObject)
|
|
115
116
|
{
|
|
116
117
|
Title = exampleObject.GetProperty<string>("title");
|
|
117
118
|
Code = exampleObject.GetProperty<string>("code");
|
|
119
|
+
Output = exampleObject.GetProperty<string>("output");
|
|
118
120
|
Remarks = exampleObject.GetProperty<PSObject[]>("remarks").EmptyIfNull().ToDescriptionText();
|
|
119
121
|
}
|
|
120
122
|
public PsHelpExampleInfo(MarkdownExampleHelpInfo markdownExample)
|
|
121
123
|
{
|
|
122
124
|
Title = markdownExample.Name;
|
|
123
125
|
Code = markdownExample.Code;
|
|
126
|
+
Output = markdownExample.Output;
|
|
124
127
|
Remarks = markdownExample.Description;
|
|
125
128
|
}
|
|
126
129
|
|
|
@@ -91,12 +91,17 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
91
91
|
var code = codeStartIndex.HasValue && codeEndIndex.HasValue
|
|
92
92
|
? String.Join(Environment.NewLine, eg.Skip(codeStartIndex.Value + 1).Take(codeEndIndex.Value - (codeStartIndex.Value + 1)))
|
|
93
93
|
: String.Empty;
|
|
94
|
-
var
|
|
94
|
+
var outputStartIndex = eg.Select((l, i) => l.StartsWith(ExampleOutputHeader) ? (int?)i : null).FirstOrDefault(i => i.HasValue);
|
|
95
|
+
var outputEndIndex = eg.Select((l, i) => l.StartsWith(ExampleOutputFooter) ? (int?)i : null).FirstOrDefault(i => i.HasValue && i > outputStartIndex);
|
|
96
|
+
var output = outputStartIndex.HasValue && outputEndIndex.HasValue
|
|
97
|
+
? String.Join(Environment.NewLine, eg.Skip(outputStartIndex.Value + 1).Take(outputEndIndex.Value - (outputStartIndex.Value + 1)))
|
|
98
|
+
: String.Empty;
|
|
99
|
+
var descriptionStartIndex = (outputEndIndex ?? (codeEndIndex ?? 0)) + 1;
|
|
95
100
|
descriptionStartIndex = String.IsNullOrWhiteSpace(eg[descriptionStartIndex]) ? descriptionStartIndex + 1 : descriptionStartIndex;
|
|
96
101
|
var descriptionEndIndex = eg.Length - 1;
|
|
97
102
|
descriptionEndIndex = String.IsNullOrWhiteSpace(eg[descriptionEndIndex]) ? descriptionEndIndex - 1 : descriptionEndIndex;
|
|
98
103
|
var description = String.Join(Environment.NewLine, eg.Skip(descriptionStartIndex).Take((descriptionEndIndex + 1) - descriptionStartIndex));
|
|
99
|
-
return new MarkdownExampleHelpInfo(name, code, description);
|
|
104
|
+
return new MarkdownExampleHelpInfo(name, code, output, description);
|
|
100
105
|
}).ToArray();
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -154,12 +159,14 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
154
159
|
{
|
|
155
160
|
public string Name { get; }
|
|
156
161
|
public string Code { get; }
|
|
162
|
+
public string Output { get; }
|
|
157
163
|
public string Description { get; }
|
|
158
164
|
|
|
159
|
-
public MarkdownExampleHelpInfo(string name, string code, string description)
|
|
165
|
+
public MarkdownExampleHelpInfo(string name, string code, string output, string description)
|
|
160
166
|
{
|
|
161
167
|
Name = name;
|
|
162
168
|
Code = code;
|
|
169
|
+
Output = output;
|
|
163
170
|
Description = description;
|
|
164
171
|
}
|
|
165
172
|
}
|
|
@@ -213,12 +220,12 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
213
220
|
|
|
214
221
|
internal static class MarkdownTypesExtensions
|
|
215
222
|
{
|
|
216
|
-
public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Remarks);
|
|
223
|
+
public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Output, exampleInfo.Remarks);
|
|
217
224
|
|
|
218
225
|
public static MarkdownExampleHelpInfo[] DefaultExampleHelpInfos =
|
|
219
226
|
{
|
|
220
|
-
new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"
|
|
221
|
-
new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"
|
|
227
|
+
new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"),
|
|
228
|
+
new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"),
|
|
222
229
|
};
|
|
223
230
|
|
|
224
231
|
public static MarkdownParameterHelpInfo[] SupportsShouldProcessParameters =
|