Exemple #1
0
        /*--------------------------------------------------------*/

        /// <summary>
        /// Parses the input from the user into a command string and a path string
        /// </summary>
        /// <param name="consoleInput">Input from user</param>
        private static void parseCommand(String consoleInput)
        {
            string[] inputArray = consoleInput.Split(' ');
            StatusText.setCommandInput(inputArray[0]);

            if (inputArray.Length > 1)
            {
                StatusText.setPathInput(inputArray[1]);
            }
        }
Exemple #2
0
        /*---------------------------------------------------------------------------*/

        /// <summary>
        /// Executes the command typed in by user.
        /// </summary>
        public static void executeRequest()
        {
            int commandIndex = 0;

            //Compares the command input to the list of possible commands.
            for (int i = 0; i < StatusText.getcommandInputValueArrayLength() + 1; ++i)
            {
                //A correcte instruction was entered
                if (i < StatusText.getcommandInputValueArrayLength() && StatusText.getCommandValue(i) == StatusText.getCommandInput())
                {
                    commandIndex = i;
                    break;
                }
                //A non existing instruction was entered
                else
                {
                    commandIndex = i;
                }
            }
            //End of for

            //Calls the correct method depending on the command input
            switch (commandIndex)
            {
            case 0:
                upload(StatusText.getPathInput());
                break;

            case 1:
                update(StatusText.getPathInput());
                break;

            case 2:
                delete(StatusText.getPathInput());
                break;

            case 3:
                open(StatusText.getPathInput());
                break;

            case 4:
            case 5:
                quit();
                break;

            case 6:
            case 7:
            case 10:
                showHelpScreen();
                break;

            case 8:
                create(StatusText.getPathInput());
                break;

            case 9:
                showIPs();
                break;
            }
            //End of switch

            //Erases the command just executed to prevent any misbehaviours for future requests.
            StatusText.setCommandInput("");
            StatusText.setPathInput("");
        }