aboutsummaryrefslogtreecommitdiff
path: root/src/wixcop/CommandLine/WixCopCommandLineParser.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixcop/CommandLine/WixCopCommandLineParser.cs')
-rw-r--r--src/wixcop/CommandLine/WixCopCommandLineParser.cs82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/wixcop/CommandLine/WixCopCommandLineParser.cs b/src/wixcop/CommandLine/WixCopCommandLineParser.cs
index 53012cfd..ae826d4f 100644
--- a/src/wixcop/CommandLine/WixCopCommandLineParser.cs
+++ b/src/wixcop/CommandLine/WixCopCommandLineParser.cs
@@ -1,12 +1,14 @@
1using System; 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2using System.Collections.Generic;
3using WixCop.Interfaces;
4using WixToolset.Core;
5using WixToolset.Extensibility.Data;
6using WixToolset.Extensibility.Services;
7 2
8namespace WixCop.CommandLine 3namespace WixToolset.Tools.WixCop.CommandLine
9{ 4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Core;
8 using WixToolset.Extensibility.Data;
9 using WixToolset.Extensibility.Services;
10 using WixToolset.Tools.WixCop.Interfaces;
11
10 public sealed class WixCopCommandLineParser : IWixCopCommandLineParser 12 public sealed class WixCopCommandLineParser : IWixCopCommandLineParser
11 { 13 {
12 private bool fixErrors; 14 private bool fixErrors;
@@ -89,43 +91,43 @@ namespace WixCop.CommandLine
89 91
90 switch (parameter.ToLowerInvariant()) 92 switch (parameter.ToLowerInvariant())
91 { 93 {
92 case "?": 94 case "?":
93 this.showHelp = true; 95 this.showHelp = true;
94 return true; 96 return true;
95 case "f": 97 case "f":
96 this.fixErrors = true; 98 this.fixErrors = true;
97 return true; 99 return true;
98 case "nologo": 100 case "nologo":
99 this.showLogo = false; 101 this.showLogo = false;
100 return true; 102 return true;
101 case "s": 103 case "s":
102 this.subDirectories = true; 104 this.subDirectories = true;
103 return true; 105 return true;
104 default: // other parameters 106 default: // other parameters
105 if (parameter.StartsWith("set1", StringComparison.Ordinal)) 107 if (parameter.StartsWith("set1", StringComparison.Ordinal))
106 { 108 {
107 this.settingsFile1 = parameter.Substring(4); 109 this.settingsFile1 = parameter.Substring(4);
108 } 110 }
109 else if (parameter.StartsWith("set2", StringComparison.Ordinal)) 111 else if (parameter.StartsWith("set2", StringComparison.Ordinal))
110 { 112 {
111 this.settingsFile2 = parameter.Substring(4); 113 this.settingsFile2 = parameter.Substring(4);
112 } 114 }
113 else if (parameter.StartsWith("indent:", StringComparison.Ordinal)) 115 else if (parameter.StartsWith("indent:", StringComparison.Ordinal))
116 {
117 try
114 { 118 {
115 try 119 this.indentationAmount = Convert.ToInt32(parameter.Substring(7));
116 {
117 this.indentationAmount = Convert.ToInt32(parameter.Substring(7));
118 }
119 catch
120 {
121 throw new ArgumentException("Invalid numeric argument.", parameter);
122 }
123 } 120 }
124 else 121 catch
125 { 122 {
126 throw new ArgumentException("Invalid argument.", parameter); 123 throw new ArgumentException("Invalid numeric argument.", parameter);
127 } 124 }
128 return true; 125 }
126 else
127 {
128 throw new ArgumentException("Invalid argument.", parameter);
129 }
130 return true;
129 } 131 }
130 } 132 }
131 } 133 }