@autorest/powershell 3.0.476 → 3.0.479
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 +6 -6
- package/package.json +1 -1
- package/resources/assets/create-model-cmdlets.ps1 +1 -1
- package/resources/assets/internal/README.md +2 -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": "2da9e9363bbcf4ed857ba40bd29bab8dda697bc3",
|
|
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": "207af76b132538f38a097c28203d73fcce35112b",
|
|
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",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"powershell/resources/assets/exports/README.md": "18a2a233e6efa52daf13af5336bd7880ca3faeac",
|
|
95
95
|
"powershell/resources/assets/generate-help.ps1": "c89c2d32e94fe4a62612ecb7937983cafcf528f1",
|
|
96
96
|
"powershell/resources/assets/how-to.md": "83256042bff1af1ebf54b31f8b13fbcb785677cc",
|
|
97
|
-
"powershell/resources/assets/internal/README.md": "
|
|
97
|
+
"powershell/resources/assets/internal/README.md": "d28c195826e6da6ba8f81a23d9b32083435b40f3",
|
|
98
98
|
"powershell/resources/assets/license.txt": "b9f3180fb9aff09aa7665db6b3226e492f670be6",
|
|
99
99
|
"powershell/resources/assets/pack-module.ps1": "3a263c5fd58c6f124693c3004db4b960ed579f39",
|
|
100
100
|
"powershell/resources/assets/resources/README.md": "c532566d4700f25121ebf7cd78071002f888d096",
|
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Internal
|
|
2
|
-
This directory contains a module to handle *internal only* cmdlets. Cmdlets that you **hide** in configuration are created here. For more information on hiding, see [cmdlet hiding](https://github.com/Azure/autorest/blob/
|
|
2
|
+
This directory contains a module to handle *internal only* cmdlets. Cmdlets that you **hide** in configuration are created here. For more information on hiding, see [cmdlet hiding](https://github.com/Azure/autorest.powershell/blob/main/docs/directives.md#cmdlet-hiding-exportation-suppression). The cmdlets in this directory are generated at **build-time**. Do not put any custom code, files, cmdlets, etc. into this directory. Please use `${$lib.path.relative($project.internalFolder, $project.customFolder)}` for all custom implementation.
|
|
3
3
|
|
|
4
4
|
## Info
|
|
5
5
|
- Modifiable: no
|
|
@@ -11,4 +11,4 @@ This directory contains a module to handle *internal only* cmdlets. Cmdlets that
|
|
|
11
11
|
The `${$lib.path.relative($project.internalFolder, $project.psm1Internal)}` file is generated to this folder. This module file handles the hidden cmdlets. These cmdlets will not be exported by `${$project.moduleName}`. Instead, this sub-module is imported by the `${$lib.path.relative($project.internalFolder, $project.psm1Custom)}` module, allowing you to use hidden cmdlets in your custom, exposed cmdlets. To call these cmdlets in your custom scripts, simply use [module-qualified calls](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_command_precedence?view=powershell-6#qualified-names). For example, `${$project.moduleName}.internal\Get-Example` would call an internal cmdlet named `Get-Example`.
|
|
12
12
|
|
|
13
13
|
## Purpose
|
|
14
|
-
This allows you to include REST specifications for services that you *do not wish to expose from your module*, but simply want to call within custom cmdlets. For example, if you want to make a custom cmdlet that uses `Storage` services, you could include a simplified `Storage` REST specification that has only the operations you need. When you run the generator and build this module, note the generated `Storage` cmdlets. Then, in your readme configuration, use [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) on the `Storage` cmdlets and they will *only be exposed to the custom cmdlets* you want to write, and not be exported as part of `${$project.moduleName}`.
|
|
14
|
+
This allows you to include REST specifications for services that you *do not wish to expose from your module*, but simply want to call within custom cmdlets. For example, if you want to make a custom cmdlet that uses `Storage` services, you could include a simplified `Storage` REST specification that has only the operations you need. When you run the generator and build this module, note the generated `Storage` cmdlets. Then, in your readme configuration, use [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) on the `Storage` cmdlets and they will *only be exposed to the custom cmdlets* you want to write, and not be exported as part of `${$project.moduleName}`.
|
|
@@ -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 =
|