Skip to content

Commit

Permalink
Add help and ShouldProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
markcowl committed Sep 15, 2017
1 parent e1b3725 commit 54e74a6
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 13 deletions.
15 changes: 10 additions & 5 deletions experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function New-AzWebAppJustDoIt
#>
function New-AzWebApp
{
[CmdletBinding()]
[CmdletBinding(SupportsShouldProcess=$true)]
[OutputType([Microsoft.Azure.Management.WebSites.Models.Site])]
param(
[string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName,
Expand Down Expand Up @@ -212,7 +212,8 @@ function New-AzWebApp
[string]$appName = Get-WebAppName `
-ProvidedParameters $PSBoundParameters `
-WebSitesClient $webSitesClient
Write-Progress `
if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) {
Write-Progress `
-Activity $mainActivity `
-CurrentOperation "Getting Resource Group information."
[hashtable]$groupInfo = Get-ResourceGroupInfo `
Expand Down Expand Up @@ -274,7 +275,8 @@ function New-AzWebApp

if (($PSBoundParameters.ContainsKey('AddRemote') -or $PSBoundParameters.ContainsKey('Auto')) -and $webapp) {
Add-Remote -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
}
}
}
}

END {}
Expand Down Expand Up @@ -569,7 +571,7 @@ function Get-WebSitesClient
#>
function New-AzWebAppGrayParam
{
[CmdletBinding()]
[CmdletBinding(SupportsShouldProcess=$true)]
[OutputType([Microsoft.Azure.Management.WebSites.Models.Site])]
param(
[string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName,
Expand Down Expand Up @@ -628,6 +630,8 @@ function New-AzWebAppGrayParam
-Activity $mainActivity `
-CurrentOperation "Getting App Name information."
[string]$appName = Get-WebAppNameGrayParam $PSBoundParameters $webSitesClient
if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) {

Write-Progress `
-Activity $mainActivity `
-CurrentOperation "Getting Resource Group information."
Expand Down Expand Up @@ -678,7 +682,8 @@ function New-AzWebAppGrayParam

Write-Output $webapp

Add-RemoteGrayParam -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
Add-RemoteGrayParam -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
}
}

END {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
<maml:Description><maml:para>{{Fill Location Description}}
</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type><maml:name>String</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
</maml:para>
</maml:Description>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
</maml:para>
</maml:Description>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters><command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>AddRemote</maml:name>
Expand Down Expand Up @@ -103,6 +128,15 @@
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
<maml:Description><maml:para>{{Fill Location Description}}
</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type><maml:name>String</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Group"><maml:name>ResourceGroupName</maml:name>
<maml:Description><maml:para>The name of the resource group for the Website.
</maml:para>
Expand All @@ -121,6 +155,24 @@
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes><command:inputType><dev:type><maml:name>None</maml:name>
</dev:type>
Expand Down Expand Up @@ -219,6 +271,31 @@
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
<maml:Description><maml:para>{{Fill Location Description}}
</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type><maml:name>String</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
</maml:para>
</maml:Description>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
</maml:para>
</maml:Description>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters><command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>AddRemote</maml:name>
Expand Down Expand Up @@ -257,6 +334,15 @@
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
<maml:Description><maml:para>{{Fill Location Description}}
</maml:para>
</maml:Description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type><maml:name>String</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Group"><maml:name>ResourceGroupName</maml:name>
<maml:Description><maml:para>The name of the resource group to create the website in.
</maml:para>
Expand All @@ -275,6 +361,24 @@
<maml:uri /></dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
</maml:para>
</maml:Description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type><maml:name>SwitchParameter</maml:name>
<maml:uri /></dev:type>
<dev:defaultValue>False</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes><command:inputType><dev:type><maml:name>None</maml:name>
</dev:type>
Expand Down
53 changes: 49 additions & 4 deletions experiments/Websites.Experiments/help/New-AzWebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Create a new Azure AppService website and attach it to a git repository.

```
New-AzWebApp [[-WebAppName] <String>] [[-ResourceGroupName] <String>] [[-AppServicePlan] <String>] [-Auto]
[-AddRemote] [[-GitRepositoryPath] <String>]
[-AddRemote] [[-GitRepositoryPath] <String>] [-WhatIf] [-Confirm] [-Location <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -35,7 +35,6 @@ PS C:\> New-AzWebApp contosoWebApp -Auto

Creates a web application using default settings.


## PARAMETERS

### -AddRemote
Expand Down Expand Up @@ -98,6 +97,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Location
{{Fill Location Description}}
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group for the Website.
Expand Down Expand Up @@ -128,17 +142,48 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### Microsoft.Azure.Management.WebSites.Models.Site
Details about the created website, including URL and github repo url.
## NOTES
## RELATED LINKS
Expand Down
54 changes: 50 additions & 4 deletions experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Create an Azure Website using Azure App Service.

```
New-AzWebAppGrayParam [[-WebAppName] <String>] [[-ResourceGroupName] <String>] [[-AppServicePlan] <String>]
[-Auto] [-AddRemote] [[-GitRepositoryPath] <String>] [-Location <string>]
[-Auto] [-AddRemote] [[-GitRepositoryPath] <String>] [-WhatIf] [-Confirm] -Location <String>
[<CommonParameters>]
```

## DESCRIPTION
Create an Azure Website using Azure App Service. This cmdlet uses the 'Gray Parameter' experience, which will prompt the user with default
values for parameters that are not provided. Using -Auto indicates that further prompting for defaults should not occur.


## EXAMPLES

### Example 1
Expand Down Expand Up @@ -92,6 +92,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Location
{{Fill Location Description}}
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceGroupName
The name of the resource group to create the website in.
Expand Down Expand Up @@ -122,17 +137,48 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### Microsoft.Azure.Management.WebSites.Models.Site
Details about the created website, including its URL.
## NOTES
## RELATED LINKS
Expand Down

0 comments on commit 54e74a6

Please sign in to comment.