Skip to content

Commit e162407

Browse files
committed
clean up wording and simplify
1 parent 739e427 commit e162407

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

1-Draft/RFCNNNN-Optional-Features.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ Plan to implement: Yes
1111

1212
# Optional features in PowerShell
1313

14-
There are several important issues in the PowerShell language that cannot be corrected without introducing breaking changes. At the same time, the number of breaking changes introduced in a new version of PowerShell needs to be as minimal as possible, so that there is a low barrier to adoption of new versions, allowing community members can transition scripts and modules across versions more easily. Given that those two statements are in conflict with one another, we need to consider how we can optionally introduce breaking changes into PowerShell over time.
14+
There are several important issues in the PowerShell language that cannot be corrected without introducing breaking changes. At the same time, the number of breaking changes introduced in a new version of PowerShell needs to be as minimal as possible, so that there is a low barrier to adoption of new versions, allowing community members to transition scripts and modules across versions more easily. Given that those two statements are in conflict with one another, we need to consider how we can optionally introduce breaking changes into PowerShell over time.
1515

16-
PowerShell has support for experimental features, which some may think covers this need; however, the intent of experimental features is to allow the community to try pre-release versions of PowerShell with breaking changes that are deemed necessary so that they can more accurately assess the impact of those breaking changes. For release versions of PowerShell, an experimental feature has one of three possible outcomes:
16+
PowerShell has support for experimental features, which some may think covers this need; however, the intent of experimental features is to allow the community to try pre-release versions of PowerShell with breaking changes that are deemed necessary or new features that are not necessarily fully tested/polished so that they can more accurately assess the impact of those features. For release versions of PowerShell, an experimental feature has one of three possible outcomes:
1717

18-
1. The breaking change in the experimental feature is deemed necessary and accepted by the community as not harmful to adoption of new versions, in which case the experimental feature is no longer marked as experimental.
19-
1. The breaking change in the experimental feature is deemed necessary, but considered harmful to adoption of new versions, in which case the experimental feature is changed to an optional feature.
20-
1. The breaking change in the experimental feature is deemed not useful enough, in which case the experimental feature is deprecated.
18+
1. The the experimental feature is deemed necessary, adequately tested/polished and accepted by the community as not harmful to adoption of new versions, in which case the experimental feature is no longer marked as experimental.
19+
1. The experimental feature is deemed necessary, and adequately tested/polished, but considered harmful to adoption of new versions, in which case the experimental feature is changed to an optional feature.
20+
1. The experimental feature is deemed not useful enough, in which case the experimental feature is deprecated.
2121

22-
In some cases a breaking change may be implemented immediately as an optional feature, when it is known up front that such a breaking change would be considered harmful to adoption of new versions of PowerShell.
22+
In some cases a breaking change may be implemented immediately as an optional feature, when it is known up front that such a breaking change would be considered harmful to adoption of new versions of PowerShell if it was in place by default yet is still found important enough to implement as an optional feature.
2323

2424
Given all of that, we need to add support for optional features in PowerShell so that what is described above becomes a reality.
2525

@@ -28,8 +28,8 @@ As an example of a feature that will be optional if implemented, see RFCNNNN-Pro
2828
## Motivation
2929

3030
As a script, function, or module author,
31-
I can enable optional features in my scripts or modules,
32-
so that I can leverage new functionality that could break existing scripts.
31+
I can enable optional features in specific scopes,
32+
so that I can leverage new functionality that may break existing scripts without risk.
3333

3434
## User experience
3535

@@ -53,7 +53,8 @@ New-ModuleManifest -Path ./test.psd1 -OptionalFeatures @('OptionalFeature1',@{Na
5353
5454
# Create a script file, enabling or disabling one or more optional features in the file
5555
@'
56-
#requires -OptionalFeature OptionalFeature1,@{Name='OptionalFeature2';Enabled=$false}
56+
#requires -OptionalFeature OptionalFeature1
57+
#requires -OptionalFeature OptionalFeature2 -Disabled
5758
5859
<snip>
5960
'@ | Out-File -FilePath ./test.ps1
@@ -107,7 +108,7 @@ Disable-OptionalFeature -Name OptionalFeature1 -UserScope CurrentUser
107108
# Output:
108109
# None, unless the feature was explicitly enabled for all users and is being
109110
# disabled only for the current user as an override, as is the case here,
110-
# in which case they get prompted to confirm.
111+
# in which case they get prompted to confirm. This is described below.
111112
112113
# Enable an optional feature in all new module manifests created with
113114
# New-ModuleManifest in the current and future PowerShell sessions for any user
@@ -125,10 +126,16 @@ Disable-OptionalFeature -Name OptionalFeature3 -NewModuleManifests
125126
# Output:
126127
# None
127128
128-
# Enable an optional feature the duration of the script block being invoked.
129-
Use-OptionalFeature -Name OptionalFeature1 -ScriptBlock {
129+
# Enable and disable an optional feature the duration of the script block being
130+
# invoked.
131+
Use-OptionalFeature -Enable OptionalFeature1 -Disable OptionalFeature2 -ScriptBlock {
130132
# Do things using OptionalFeature1 here
133+
# OptionalFeature2 cannot be used here
131134
}
135+
# If OptionalFeature1 was not enabled before this invocation, it is still no
136+
# longerenabled here. If OptionalFeature2 was enabled before this invocation,
137+
# it is still enabled here. All to say, their state before the call is
138+
# preserved.
132139
```
133140

134141
## Specification
@@ -158,13 +165,9 @@ A terminating error is generated if the same optional feature name is used twice
158165

159166
### Add parameter set to #requires statement
160167

161-
`#requires -OptionalFeatures <object[]>`
168+
`#requires -OptionalFeatures <string[]> [-Disabled]`
162169

163-
This parameter set would enable optional features in the current script file.
164-
165-
Entries in this collection would either be string (the name of the optional feature to enable) or a hashtable with two keys: `name` and `enabled`. The hashtable allows an optional feature to be specifically disabled instead of enabled within a script.
166-
167-
A terminating error is generated if the same optional feature name is used twice in the collection passed into the `-OptionalFeatures` parameter.
170+
This parameter set would enable, or disable if `-Disabled` is used, optional features identified by `-Name` in the current script file.
168171

169172
### New command: Get-OptionalFeatureConfiguration
170173

@@ -222,10 +225,10 @@ The `Disable-OptionalFeature` command will disable an optional feature in curren
222225
### New command: Use-OptionalFeature
223226

224227
```none
225-
Use-OptionalFeature [-Name] <string[]> [-ScriptBlock] <ScriptBlock> [-Confirm] [<CommonParameters>]
228+
Use-OptionalFeature [[-Enable] <string[]>] [[-Disable] <string[]>] [-ScriptBlock] <ScriptBlock> [-Confirm] [<CommonParameters>]
226229
```
227230

228-
This command would enable an optional feature for the duration of the `ScriptBlock` identified in the `-ScriptBlock` parameter, and return the feature to its previous state afterwards. This allows for easy use of an optional feature over a small section of code.
231+
This command would enable or disable the optional features whose names are identified in the `-Enable` and `-Disable` parameters for the duration of the `ScriptBlock` identified in the `-ScriptBlock` parameter, and return the features to their previous state afterwards. This allows for easy use of optional features over a small section of code. If neither `-Enable` or `-Disable` are used, a terminating error is thrown.
229232

230233
### Checking optional feature states within the PowerShell runtime
231234

0 commit comments

Comments
 (0)