/// <summary> /// Parse the command line options/ arguments and populate the command /// object with the arguments. /// </summary> /// <param name="command"></param> /// <param name="options">A string value that holds the command /// line options the user has selected.</param> /// <exception cref="NotImplementedException">If the command argument /// is not implemented currently. TODO: Implement the argument.</exception> private void ParseOptions (StatusCommand command, string[] options) { int currentOptionIndex = 0; while (currentOptionIndex < options.Length) { string currentOption = options[currentOptionIndex]; switch (currentOption) { case "-v": command.Verbose = true; break; case "-l": command.LocalOnly = true; break; case "-R": command.Recursive = true; break; case "-q": command.Terse = true; break; case "-x": command.CvsNt2Output = true; break; case "-X": command.Cvs1Output = true; break; default: // if a switch is passed in that we don't know about // then throw an exception if (currentOption.StartsWith("-")) { throw new NotSupportedException( string.Format("Unknown option specified: {0}", currentOption)); } // otherwise the parameter is probably a file or module name, ignore break; } } this.ParseFiles(options); }
/// <summary> /// Create the command object that will be used to act on the repository. /// </summary> /// <returns>The command object that will be used to act on the /// repository.</returns> /// <exception cref="Exception">TODO: Make a more specific exception</exception> /// <exception cref="NotImplementedException">If the command argument /// is not implemented currently. TODO: Implement the argument.</exception> public override ICommand CreateCommand () { DirectoryInfo dir = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "CVS")); StatusCommand statusCommand; this.localDirectory = Directory.GetCurrentDirectory(); try { this.repository = Repository.Load(dir).FileContents; this.CvsRoot = new CvsRoot(Root.Load(dir).FileContents); } catch (NullReferenceException) { this.InvalidRepository(); } catch (CvsFileNotFoundException) { this.InvalidRepository(); } catch (ICSharpCode.SharpCvsLib.Exceptions.CvsRootParseException) { this.InvalidRepository(); } CurrentWorkingDirectory = new WorkingDirectory(this.CvsRoot, localDirectory, this.repository); // Create new command object statusCommand = new StatusCommand(CurrentWorkingDirectory); statusCommand.Folders = this.GetCurrentDirectory(new DirectoryInfo(localDirectory)); this.ParseOptions(statusCommand, this.Args); return statusCommand; }