/// <summary>
 ///
 /// </summary>
 /// <param name="wantsHelp"></param>
 /// <param name="isTest"></param>
 /// <param name="useRunSet"></param>
 /// <param name="runSetName"></param>
 public CommandLineSettings(
     bool wantsHelp,
     bool isTest,
     SmartLib.Model.TriState useRunSet,
     System.String runSetName
     )
 {
     WantsHelp  = wantsHelp;
     IsTest     = isTest;
     UseRunSet  = useRunSet;
     RunSetName = runSetName;
 }
Example #2
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public CommandLine(
			System.String[] args
			)
		{
			if (args == null)
			{
				throw new System.ArgumentNullException("args");
			}

			if (args.Length == 0)
			{
				CommandLineSettings = new Model.CommandLineSettings(
					true,
					false,
					SmartLib.Model.TriState.Undefined,
					null
					);
				return;
			}

			System.Collections.Generic.List<System.String> argCollection
				= new System.Collections.Generic.List<System.String>(args);

			//check if /? specified
			bool wantsHelp = GetIsSingleArgumentSpecified(
				argCollection,
				"/?"
				);

			bool isTest = false;
			SmartLib.Model.TriState useRunSet = SmartLib.Model.TriState.Undefined;
			System.String runSetName = null;

			if (!wantsHelp)
			{
				//check for /test
				isTest = GetIsSingleArgumentSpecified(
					argCollection,
					"/test"
					);

				//check for /norunset
				if (GetIsSingleArgumentSpecified(
					argCollection,
					"/norunset"
					))
				{
					useRunSet = SmartLib.Model.TriState.No;
				}

				//check for /runset
				System.String value = null;
				if (GetIsPairArgumentsSpecified(
					argCollection,
					"/runset",
					ref value
					))
				{
					if (useRunSet == SmartLib.Model.TriState.No)
					{
						//we've already had /norunset
						//which is mutually exclusive
						throw new System.ArgumentException(
							"/norunset and /runset specified. These are mutually exclusive arguments, use one or the other."
							);
					}
					useRunSet = SmartLib.Model.TriState.Yes;
					runSetName = value;
				}

				if (argCollection.Count > 0)
				{
					//1 or more arguments haven't been handled
					throw new System.ArgumentException(
						"Unhandled arguments."
						);
				}
			}

			CommandLineSettings = new Model.CommandLineSettings(
				wantsHelp,
				isTest,
				useRunSet,
				runSetName
				);
		}