You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/directives.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,7 +215,7 @@ Some generated cmdlets include PowerShell `SupportsShouldProcess` semantics, exp
215
215
216
216
Use `suppress-should-process` to explicitly disable `SupportsShouldProcess` for selected cmdlets so that `-WhatIf` and `-Confirm` are not generated.
217
217
218
-
This directive was introduced to address scenarios like issue #704, where `listKeys` style operations were generated with unnecessary confirmation switches.
218
+
This directive was introduced to address scenarios like issue [#704](https://github.com/Azure/autorest.powershell/issues/704), where `listKeys` style operations were generated with unnecessary confirmation switches.
219
219
220
220
Usage:
221
221
- Target the cmdlet with the usual command filters (`verb`, `subject`, `subject-prefix`, and/or `variant`).
@@ -248,7 +248,7 @@ Notes:
248
248
- Use sparingly; only when you are certain the underlying operation is non-mutating.
249
249
250
250
### Parameter Rename
251
-
To select a parameter you need to provide the `parameter-name`. Furthermore, if you want to target specific cmdlets you can provide the `subject-prefix`, `subject`, `verb`, and/or `variant` (i.e. parameter-set name). For example:
251
+
To select a parameter you need to provide the `parameter-name`. Furthermore, if you want to target specific cmdlets you can provide the `subject-prefix`, `subject`, `verb`, and/or `variant` (i.e. parameter-set). For example:
252
252
```yaml false
253
253
# This will rename the parameter 'XYZName' from the cmdlet 'Get-Operation' to 'Name'.
254
254
directive:
@@ -349,7 +349,7 @@ directive:
349
349
```
350
350
351
351
### Model Cmdlet
352
-
To generate a cmdlet for a model facilitating users in constructing complex objects, you can choose the model using `model-name`. The default cmdlet name generated will be New-Az[subject-prefix][model-name]Object (or equivalent based on module naming). For example:
352
+
To generate a cmdlet for a model facilitating users in constructing complex objects, you can choose the model using `model-name`. The default cmdlet name generated will be New-Az[subject-prefix][model-name]Object, and you can customize it using `cmdlet-name`. For example:
353
353
```yaml $false
354
354
- model-cmdlet:
355
355
- model-name: Workspace
@@ -383,7 +383,7 @@ directive:
383
383
```
384
384
385
385
### Alias Removal
386
-
If the option `--sanitize-names` or `--azure` is provided, AutoRest will make renames to cmdlets and parameters to remove redundancies. For example in the command `Get-VirtualMachine`, the parameter `VirtualMachineName` may become just `Name`. To remove an automatically generated alias:
386
+
If the option `--sanitize-names` or `--azure` is provided, AutoRest will make renames to cmdlets and parameters to remove redundancies. For example in the command `Get-VirtualMachine`, the parameter `VirtualMachineName` will be renamed to `Name`, and aliased to VirtualMachineName. It is possible to eliminate that alias by providing the action `clear-alias: true`:
387
387
```yaml $false
388
388
directive:
389
389
- where:
@@ -393,7 +393,7 @@ directive:
393
393
The same can be done with cmdlets.
394
394
395
395
### Table Formatting
396
-
This allows you to set the *table format* for a model. This updates the `.format.ps1xml` to have the format described below as opposed to the automatic table format that is created at build-time. For example:
396
+
This allows you to set the *table format* for a model. This updates the `.format.ps1xml` to have the format described below as opposed to the automatic table format that is created at build-time. For example, we are updating the format for a VirtualMachine model to only show the Name and ResourceGroup properties. It updates the column label for ResourceGroup to Resource Group and sets the columns widths for Name and ResourceGroup:
397
397
```yaml $false
398
398
directive:
399
399
- where:
@@ -432,7 +432,7 @@ directive:
432
432
```
433
433
434
434
### Argument Completers
435
-
For parameters, you can declare argument completers that will allow you to tab through the values when entering that parameter interactively. This allows you to declare a PowerShell script that will run to produce the possible values for that parameter.
435
+
For parameters, you can declare argument completers that will allow you to tab through the values when entering that parameter interactively. This allows you to declare a PowerShell script that will run to get the values for the completer. For example:
436
436
```yaml $false
437
437
# The script should return a list of values.
438
438
directive:
@@ -447,7 +447,7 @@ directive:
447
447
The name and description are optional. They are currently unused properties that may be used in documentation generation in the future.
448
448
449
449
### Default Values
450
-
For parameters, you can declare a default value script that will run to set the value for the parameter if it is not provided. Once this is declared for a parameter, that parameter will be made optional (unless there are other constraints).
450
+
For parameters, you can declare a default value script that will run to set the value for the parameter if it is not provided. Once this is declared for a parameter, that parameter will be made optional at build-time. For example:
451
451
```yaml $false
452
452
# The script should return a value for the parameter.
453
453
directive:
@@ -463,7 +463,7 @@ The name and description are optional. They are currently unused properties that
463
463
464
464
### Polymorphism
465
465
466
-
In swagger, polymorphism is recognized as the `discriminator` keyword. The model with this keyword will be the **base class**, and the models that use `allOf` to referece the base class are the **child classes**.
466
+
In swagger, polymorphism is recognized as the `discriminator` keyword. The model with this keyword will be the **base class**, and the models that use `allOf` to referece the base class are the **child class**.
467
467
468
468
We will use two directives to support polymorphism:
0 commit comments