Beispiel #1
0
        /// <summary>
        /// Parse the command line options.  There are two (2) general sweeps
        ///     at parsing the command line.  The first sweep looks for command line
        ///     help switches, denoted by -- parameters.
        /// </summary>
        /// <returns>A command object from the library which will be used to
        ///     access the repsository.</returns>
        /// <exception cref="CommandLineParseException">If there is a problem
        ///     parsing the command line arguments (i.e. if invalid arguments
        ///     are entered.</exception>
        public ICommand Execute()
        {
            if (LOGGER.IsDebugEnabled)
            {
                StringBuilder msg = new StringBuilder();
                msg.Append("\n Command line arguments:");
                foreach (String argument in this.arguments)
                {
                    msg.Append("\n\t argument=[").Append(argument).Append("]");
                }
                LOGGER.Debug(msg);
            }

            bool isHelp = this.ParseHelp(this.arguments);

            if (isHelp)
            {
                return(null);
            }

            int startIndex = 0;
            // TODO: Remove = null when all other code paths return a value,
            //      this was just put in so it would compile.
            ICommand command = null;

            if (arguments.Length < 1)
            {
                System.Console.WriteLine(Usage.General);
            }

            if (arguments.Length > 0 &&
                (arguments[0] == "-d"))
            {
                this.cvsRoot = new CvsRoot(this.arguments[1]);
                startIndex   = 2;
            }
            else if (arguments.Length > 0 &&
                     (arguments[0].Length > 2) &&
                     arguments[0].Substring(0, 2) == "-d")
            {
                this.cvsRoot = new CvsRoot(this.arguments[0].Substring(2).Trim());
                startIndex   = 1;
            }

            for (int i = startIndex; i < arguments.Length; i++)
            {
                if (LOGGER.IsDebugEnabled)
                {
                    StringBuilder msg = new StringBuilder();
                    msg.Append("arguments[").Append(i).Append("]=[").Append(arguments[i]).Append("]");
                    LOGGER.Debug(msg);
                }
                LOGGER.Debug("Before we grab the arguments.");
                string commandString = arguments[i].Trim();
                CommandParserFactory factory;
                ICommandParser       parser;
                switch (commandString)
                {
                case "add":
                case "ad":
                case "new":
                    // no single options for the Add command
                    this.commandTxt = arguments[i];
                    i++;
                    // get rest of arguments which is options on the commit command.
                    while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0)
                    {
                        // Get options with second parameters?
                        if (arguments[i].IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i++];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.repository = arguments[i];
                    }
                    else
                    {
                        this.repository = String.Empty;
                    }
                    AddCommandParser addCommand =
                        new AddCommandParser(this.CvsRoot, repository, options);
                    command = addCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        addCommand.CurrentWorkingDirectory;
                    break;

                case "commit":
                case "ci":
                case "com":
                    singleOptions   = "DRcfln";
                    this.commandTxt = arguments[i];
                    i++;
                    // get rest of arguments which is options on the commit command.
                    while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0)
                    {
                        LOGGER.Debug("Parsing arguments.  Argument[" + i + "]=[" + arguments[i]);
                        // Get options with second parameters?
                        if (arguments[i].IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i++];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.repository = arguments[i];
                    }
                    else
                    {
                        this.repository = String.Empty;
                    }
                    CommitCommandParser commitCommand =
                        new CommitCommandParser(this.CvsRoot, repository, options);
                    command = commitCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        commitCommand.CurrentWorkingDirectory;
                    break;

                case "checkout":
                case "co":
                case "get":
                    singleOptions   = "ANPRcflnps";
                    this.commandTxt = arguments[i];
                    i++;
                    // get rest of arguments which is options on the checkout command.
                    while (arguments.Length > i && arguments[i].Trim().IndexOf("-") == 0)
                    {
                        // Get options with second parameters?
                        if (arguments[i].Trim().IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i++];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.repository = arguments[i];
                    }
                    else
                    {
                        this.repository = String.Empty;
                    }
                    CheckoutCommandParser checkoutCommand =
                        new CheckoutCommandParser(this.CvsRoot, this.Repository, options);
                    command = checkoutCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        checkoutCommand.CurrentWorkingDirectory;
                    break;

                case "import":
                case "imp":
                case "im":
                    i++;
                    string [] tempArgs = new string[arguments.Length - i];
                    Array.Copy(arguments, i, tempArgs, 0, arguments.Length - i);
                    ImportCommandParser importCommand =
                        new ImportCommandParser(this.CvsRoot, tempArgs);
                    command = importCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        importCommand.CurrentWorkingDirectory;
                    i = arguments.Length;
                    break;

                case "init":
                    this.commandTxt = arguments[i];
                    InitCommandParser initCommand = new InitCommandParser(this.CvsRoot);
                    command = initCommand.CreateCommand();
                    this.currentWorkingDirectory = initCommand.CurrentWorkingDirectory;
                    break;

                case "log":
                case "lo":
                    this.commandTxt = arguments[i++];
                    string[] logArgs = new string[arguments.Length - i];
                    Array.Copy(arguments, i, logArgs, 0, arguments.Length - i);
                    LogCommandParser logCommandParser =
                        new LogCommandParser(this.CvsRoot, logArgs);
                    command = logCommandParser.CreateCommand();
                    this.currentWorkingDirectory = logCommandParser.CurrentWorkingDirectory;
                    i = arguments.Length;
                    break;

                case "login":
                case "logon":
                case "lgn":
                    // login to server
                    this.commandTxt = arguments[i];
                    LoginCommand loginCommand =
                        new LoginCommand(this.CvsRoot, this.currentWorkingDirectory);
                    loginCommand.Args            = arguments;
                    this.currentWorkingDirectory = loginCommand.CurrentWorkingDirectory;
                    command = loginCommand;
                    break;

                case "dir":
                case "list":
                case "ls":
                    factory =
                        new CommandParserFactory("ls", arguments,
                                                 this.cvsRoot, this.currentWorkingDirectory);

                    parser  = factory.GetCommandParser();
                    i       = arguments.Length;
                    command = parser.CreateCommand();
                    this.currentWorkingDirectory =
                        parser.CurrentWorkingDirectory;
                    break;

                case "passwd":
                case "password":
                case "setpass":
                    this.commandTxt = arguments[i];
                    break;

                case "remove":
                case "delete":
                case "rm":
                    singleOptions   = "Rfl";
                    this.commandTxt = arguments[i];
                    i++;
                    // get rest of arguments which is options on the update command.
                    while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0)
                    {
                        // Get options with second parameters?
                        if (arguments[i].IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.files = arguments[i++];
                    }
                    else
                    {
                        this.files = String.Empty;
                    }
                    RemoveCommandParser removeCommand =
                        new RemoveCommandParser(this.CvsRoot, files, options);
                    command = removeCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        removeCommand.CurrentWorkingDirectory;
                    break;

                case "rt":
                case "rtag":
                case "rtfreeze":
                    singleOptions   = "abBdfFlMnR";
                    this.commandTxt = arguments[i++];
                    // get rest of arguments which is options on the rtag command.
                    while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0)
                    {
                        // Get options with second parameters?
                        if (arguments[i].IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.repository = arguments[i++];
                    }
                    else
                    {
                        this.repository = String.Empty;
                    }
                    RTagCommandParser rtagCommand =
                        new RTagCommandParser(this.CvsRoot, repository, options);
                    command = rtagCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        rtagCommand.CurrentWorkingDirectory;
                    break;

                case "st":
                case "stat":
                case "status":
                    string[] commandArgs = new string[arguments.Length - i];
                    Array.Copy(arguments, i, commandArgs, 0, arguments.Length - i);
                    factory =
                        new CommandParserFactory("status", commandArgs,
                                                 this.cvsRoot, this.currentWorkingDirectory);

                    parser  = factory.GetCommandParser();
                    i       = arguments.Length;
                    command = parser.CreateCommand();
                    this.currentWorkingDirectory =
                        parser.CurrentWorkingDirectory;
                    break;

                case "up":
                case "upd":
                case "update":
                    singleOptions   = "ACPRbdfmp";
                    this.commandTxt = arguments[i++];
                    // get rest of arguments which is options on the update command.
                    while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0)
                    {
                        // Get options with second parameters?
                        if (arguments[i].IndexOfAny(singleOptions.ToCharArray(), 1, 1) >= 0)
                        {
                            for (int cnt = 1; cnt < arguments[i].Length; cnt++)
                            {
                                this.options = this.options + "-" + arguments[i][cnt] + " ";     // No
                            }
                        }
                        else
                        {
                            this.options = this.options + arguments[i];           // Yes
                            this.options = this.options + arguments[i] + " ";
                        }
                        i++;
                    }
                    if (arguments.Length > i)
                    {
                        // Safely grab the module, if not specified then
                        //  pass null into the repository...the cvs command
                        //  line for cvsnt/ cvs seems to bomb out when
                        //  it sends to the server
                        this.repository = arguments[i++];
                    }
                    else
                    {
                        this.repository = String.Empty;
                    }
                    UpdateCommandParser updateCommand =
                        new UpdateCommandParser(this.CvsRoot, repository, options);
                    command = updateCommand.CreateCommand();
                    this.currentWorkingDirectory =
                        updateCommand.CurrentWorkingDirectory;
                    break;

                case "xml":
                    factory =
                        new CommandParserFactory("xml", arguments,
                                                 this.cvsRoot, this.currentWorkingDirectory);

                    // TODO: Move this outside of case statement when all commands use same pattern
                    parser  = factory.GetCommandParser();
                    i       = arguments.Length;
                    command = parser.CreateCommand();
                    this.currentWorkingDirectory =
                        parser.CurrentWorkingDirectory;

                    break;

                default:
                    StringBuilder msg = new StringBuilder();
                    msg.Append("Unknown command entered.  ");
                    msg.Append("command=[").Append(arguments[i]).Append("]");
                    throw new CommandLineParseException(msg.ToString());
                }
            }
            return(command);
        }
        /// <summary>
        /// Parse the command line options.  There are two (2) general sweeps
        ///     at parsing the command line.  The first sweep looks for command line
        ///     help switches, denoted by -- parameters.     
        /// </summary>
        /// <returns>A command object from the library which will be used to 
        ///     access the repsository.</returns>
        /// <exception cref="CommandLineParseException">If there is a problem
        ///     parsing the command line arguments (i.e. if invalid arguments
        ///     are entered.</exception>
        public ICommand Execute () {
            if (LOGGER.IsDebugEnabled) {
                StringBuilder msg = new StringBuilder ();
                msg.Append("\n Command line arguments:");
                foreach (String argument in this.arguments) {
                    msg.Append("\n\t argument=[").Append(argument).Append("]");
                }
                LOGGER.Debug(msg);
            }

            bool isHelp = this.ParseHelp (this.arguments);

            if (isHelp) {
                return null;
            }

            int startIndex = 0;
            // TODO: Remove = null when all other code paths return a value,
            //      this was just put in so it would compile.
            ICommand command = null;
            if (arguments.Length < 1) {
                System.Console.WriteLine (Usage.General);
            }

            if (arguments.Length > 0 && 
                (arguments[0] == "-d")) {
                this.cvsRoot = new CvsRoot(this.arguments[1]);
                startIndex = 2;                
            } else if (arguments.Length > 0 && 
                (arguments[0].Length > 2) && 
                arguments[0].Substring(0, 2) == "-d") {
                this.cvsRoot = new CvsRoot(this.arguments[0].Substring(2).Trim());
                startIndex = 1;
            }

            for (int i = startIndex; i < arguments.Length; i++) {
                if (LOGGER.IsDebugEnabled) {
                    StringBuilder msg = new StringBuilder ();
                    msg.Append("arguments[").Append(i).Append("]=[").Append(arguments[i]).Append("]");
                    LOGGER.Debug(msg);
                }
                LOGGER.Debug("Before we grab the arguments.");
                string commandString = arguments[i].Trim();
                CommandParserFactory factory;
                ICommandParser parser;
                switch (commandString) {
                    case "add":
                    case "ad":
                    case "new":
                        // no single options for the Add command
                        this.commandTxt = arguments[i];
                        i++;
                        // get rest of arguments which is options on the commit command.
                        while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) {
                            // Get options with second parameters?
                            if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) {
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) {
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            }
                            else {
                                this.options = this.options + arguments[i++];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i) {
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.repository = arguments[i];
                        } 
                        else {
                            this.repository = String.Empty;
                        }
                        AddCommandParser addCommand = 
                            new AddCommandParser(this.CvsRoot, repository, options);
                        command = addCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            addCommand.CurrentWorkingDirectory;
                        break;
                    case "commit":
                    case "ci":
                    case "com":
                        singleOptions = "DRcfln";
                        this.commandTxt = arguments[i];
                        i++;
                        // get rest of arguments which is options on the commit command.
                        while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) {
                            LOGGER.Debug("Parsing arguments.  Argument[" + i + "]=[" + arguments[i]);
                            // Get options with second parameters?
                            if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) {
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) {
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            }
                            else {
                                this.options = this.options + arguments[i++];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i) {
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.repository = arguments[i];
                        } 
                        else {
                            this.repository = String.Empty;
                        }
                        CommitCommandParser commitCommand = 
                            new CommitCommandParser(this.CvsRoot, repository, options);
                        command = commitCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            commitCommand.CurrentWorkingDirectory;
                        break;
                    case "checkout":
                    case "co":
                    case "get":
                        singleOptions = "ANPRcflnps";
                        this.commandTxt = arguments[i];
                        i++;
                        // get rest of arguments which is options on the checkout command.
                        while (arguments.Length > i && arguments[i].Trim().IndexOf("-") == 0){
                            // Get options with second parameters?
                            if (arguments[i].Trim().IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0){
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ){
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            }
                            else{
                                this.options = this.options + arguments[i++];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i){
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.repository = arguments[i];
                        } else {
                            this.repository = String.Empty;
                        }
                        CheckoutCommandParser checkoutCommand = 
                            new CheckoutCommandParser(this.CvsRoot, this.Repository, options);
                        command = checkoutCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            checkoutCommand.CurrentWorkingDirectory;
                        break;
                    case "import":
                    case "imp":
                    case "im":
                        i++;
                        string [] tempArgs = new string[arguments.Length - i];
                        Array.Copy(arguments, i, tempArgs, 0, arguments.Length - i);
                        ImportCommandParser importCommand = 
                            new ImportCommandParser(this.CvsRoot, tempArgs);
                        command = importCommand.CreateCommand();
                        this.currentWorkingDirectory =
                            importCommand.CurrentWorkingDirectory;
                        i = arguments.Length;
                        break;
                    case "init":
                        this.commandTxt = arguments[i];
                        InitCommandParser initCommand = new InitCommandParser(this.CvsRoot);
                        command = initCommand.CreateCommand ();
                        this.currentWorkingDirectory = initCommand.CurrentWorkingDirectory;
                        break;
                    case "log":
                    case "lo":
                        this.commandTxt = arguments[i++];
                        string[] logArgs = new string[arguments.Length - i];
                        Array.Copy(arguments, i, logArgs, 0, arguments.Length - i);
                        LogCommandParser logCommandParser = 
                            new LogCommandParser(this.CvsRoot, logArgs);
                        command = logCommandParser.CreateCommand();
                        this.currentWorkingDirectory = logCommandParser.CurrentWorkingDirectory;
                        i = arguments.Length;
                        break;
                    case "login":
                    case "logon":
                    case "lgn":
                        // login to server
                        this.commandTxt = arguments[i];
                        LoginCommand loginCommand = 
                            new LoginCommand(this.CvsRoot, this.currentWorkingDirectory);
                        loginCommand.Args = arguments;
                        this.currentWorkingDirectory = loginCommand.CurrentWorkingDirectory;
                        command = loginCommand;
                        break;
                    case "dir":
                    case "list":
                    case "ls":
                        factory = 
                            new CommandParserFactory("ls", arguments, 
                            this.cvsRoot, this.currentWorkingDirectory);

                        parser = factory.GetCommandParser();
                        i = arguments.Length;
                        command = parser.CreateCommand();
                        this.currentWorkingDirectory = 
                            parser.CurrentWorkingDirectory;
                        break;
                    case "passwd":
                    case "password":
                    case "setpass":
                        this.commandTxt = arguments[i];
                        break;
                    case "remove":
                    case "delete":
                    case "rm":
                        singleOptions = "Rfl";
                        this.commandTxt = arguments[i];
                        i++;
                        // get rest of arguments which is options on the update command.
                        while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) {
                            // Get options with second parameters?
                            if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) {
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) {
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            } 
                            else {
                                this.options = this.options + arguments[i];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i) {
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.files = arguments[i++];
                        } 
                        else {
                            this.files = String.Empty;
                        }
                        RemoveCommandParser removeCommand = 
                            new RemoveCommandParser(this.CvsRoot, files, options);
                        command = removeCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            removeCommand.CurrentWorkingDirectory;
                        break;
                    case "rt":
                    case "rtag":
                    case "rtfreeze":
                        singleOptions = "abBdfFlMnR";
                        this.commandTxt = arguments[i++];
                        // get rest of arguments which is options on the rtag command.
                        while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) {
                            // Get options with second parameters?
                            if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) {
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) {
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            } 
                            else {
                                this.options = this.options + arguments[i];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i) {
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.repository = arguments[i++];
                        } 
                        else {
                            this.repository = String.Empty;
                        }
                        RTagCommandParser rtagCommand = 
                            new RTagCommandParser(this.CvsRoot, repository, options);
                        command = rtagCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            rtagCommand.CurrentWorkingDirectory;
                        break;
                    case "st":
                    case "stat":
                    case "status":
                        string[] commandArgs = new string[arguments.Length - i];
                        Array.Copy(arguments, i, commandArgs, 0, arguments.Length - i);
                        factory = 
                            new CommandParserFactory("status", commandArgs, 
                            this.cvsRoot, this.currentWorkingDirectory);

                        parser = factory.GetCommandParser();
                        i = arguments.Length;
                        command = parser.CreateCommand();
                        this.currentWorkingDirectory = 
                            parser.CurrentWorkingDirectory;
                        break;
                    case "up":
                    case "upd":
                    case "update":
                        singleOptions = "ACPRbdfmp";
                        this.commandTxt = arguments[i++];
                            // get rest of arguments which is options on the update command.
                        while (arguments.Length > i && arguments[i].IndexOf("-", 0, 1) >= 0) {
                            // Get options with second parameters?
                            if (arguments[i].IndexOfAny( singleOptions.ToCharArray(), 1, 1) >= 0) {
                                for ( int cnt=1; cnt < arguments[i].Length; cnt++ ) {
                                    this.options = this.options + "-" + arguments[i][cnt] + " "; // No
                                }
                            } else {
                                this.options = this.options + arguments[i];       // Yes
                                this.options = this.options + arguments[i] + " ";
                            }
                            i++;
                        }
                        if (arguments.Length > i) {
                            // Safely grab the module, if not specified then
                            //  pass null into the repository...the cvs command
                            //  line for cvsnt/ cvs seems to bomb out when
                            //  it sends to the server
                            this.repository = arguments[i++];
                        } 
                        else {
                            this.repository = String.Empty;
                        }
                        UpdateCommandParser updateCommand = 
                            new UpdateCommandParser(this.CvsRoot, repository, options);
                        command = updateCommand.CreateCommand ();
                        this.currentWorkingDirectory = 
                            updateCommand.CurrentWorkingDirectory;
                        break;
                    case "xml":
                        factory = 
                            new CommandParserFactory("xml", arguments, 
                            this.cvsRoot, this.currentWorkingDirectory);

                        // TODO: Move this outside of case statement when all commands use same pattern
                        parser = factory.GetCommandParser();
                        i = arguments.Length;
                        command = parser.CreateCommand();
                        this.currentWorkingDirectory = 
                            parser.CurrentWorkingDirectory;

                        break;
                    default:
                        StringBuilder msg = new StringBuilder ();
                        msg.Append("Unknown command entered.  ");
                        msg.Append("command=[").Append(arguments[i]).Append("]");
                        throw new CommandLineParseException(msg.ToString());
                    }
                }
            return command;
        }