Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KoenZomers committed Jun 30, 2024
1 parent ac400c3 commit 4e1a89d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions documentation/Export-PnPTaxonomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ If specified will exclude the deprecated taxonomy items in the output. Applicabl
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Parameter Sets: TermSet

Required: False
Position: Named
Expand All @@ -161,7 +161,7 @@ Specify the language code for the exported terms
```yaml
Type: Int32
Parameter Sets: (All)
Parameter Sets: TermSet

Required: False
Position: Named
Expand Down Expand Up @@ -189,7 +189,7 @@ If specified, will export the specified termset only
```yaml
Type: Guid
Parameter Sets: (All)
Parameter Sets: TermSet

Required: False
Position: Named
Expand All @@ -203,7 +203,7 @@ Term store to export; if not specified the default term store is used.
```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: TermSet

Required: False
Position: Named
Expand Down
15 changes: 8 additions & 7 deletions src/Commands/Taxonomy/ExportTaxonomy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ namespace PnP.PowerShell.Commands.Taxonomy
[Cmdlet(VerbsData.Export, "PnPTaxonomy")]
public class ExportTaxonomy : PnPSharePointCmdlet
{
[Parameter(Mandatory = false, ParameterSetName = "TermSet")]
private const string ParameterSet_TermSet = "TermSet";

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_TermSet)]
public Guid TermSetId;

[Parameter(Mandatory = false)]
public SwitchParameter IncludeID = false;

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_TermSet)]
public SwitchParameter ExcludeDeprecated = false;

[Parameter(Mandatory = false)]
public string Path;

[Parameter(Mandatory = false, ParameterSetName = "TermSet")]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_TermSet)]
public string TermStoreName;

[Parameter(Mandatory = false)]
Expand All @@ -34,17 +36,16 @@ public class ExportTaxonomy : PnPSharePointCmdlet
[Parameter(Mandatory = false)]
public string Delimiter = "|";

[Parameter(Mandatory = false, ParameterSetName = "TermSet")]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_TermSet)]
public int Lcid = 0;

[Parameter(Mandatory = false)]
public Encoding Encoding = Encoding.Unicode;


protected override void ExecuteCmdlet()
{
List<string> exportedTerms;
if (ParameterSetName == "TermSet")
if (ParameterSetName == ParameterSet_TermSet)
{
if (Delimiter != "|" && Delimiter == ";#")
{
Expand All @@ -53,7 +54,7 @@ protected override void ExecuteCmdlet()

if (ExcludeDeprecated && Delimiter != "|")
{
throw new Exception("ExcludeDeprecated works only on the default delimiter");
throw new PSArgumentException($"{nameof(ExcludeDeprecated)} works only on the default delimiter", nameof(ExcludeDeprecated));
}

if (!string.IsNullOrEmpty(TermStoreName))
Expand Down

0 comments on commit 4e1a89d

Please sign in to comment.