public override bool ValidateParams(string line)
        {
            try
            {
                if (!ParsingUtilities.HasTwoParam(name, line))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string[] arguments   = ParsingUtilities.GetQuoteArguments(line);
            string   copyFromArg = PathTracker.CombineRelativePath(arguments[0]);
            string   copyToArg   = PathTracker.CombineRelativePath(arguments[1]);

            // Check if copyFrom file exists.
            if (!PathTracker.IsFilePathValid(copyFromArg))
            {
                throw new InvalidPathException("COPY_FILE_DOESNT_EXIST");
            }

            // Check if copyTo file doesn't exist.
            if (PathTracker.IsFilePathValid(copyToArg))
            {
                throw new InvalidPathException("COPY_FILE_ALREADY_EXISTS");
            }

            return(true);
        }
        public override bool ValidateParams(string line)
        {
            // Print command can have 1 option or 2 options.
            try
            {
                if (!(ParsingUtilities.HasOneParam(name, line) ||
                      ParsingUtilities.HasTwoParam(name, line)))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string path;

            try
            {
                string[] arguments = ParsingUtilities.GetQuoteArguments(line);
                // User has not specified encoding.
                if (!ParsingUtilities.HasOneParam(name, line))
                {
                    // Trying to find specified encoding.
                    var encodingStr = arguments[1];
                    if (!EncodingUtilities.dictStrEncoding.ContainsKey(encodingStr))
                    {
                        throw new InvalidEncodingException();
                    }
                }

                path = arguments[0];
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            // Check if file exists.
            if (!PathTracker.IsFilePathValid(path))
            {
                throw new InvalidPathException("FILE_NOT_FOUND");
            }

            return(true);
        }
        public override void TakeParameters(string line)
        {
            string[] arguments = ParsingUtilities.GetQuoteArguments(line);
            // First argument in quotes (path).
            filePath = arguments[0];

            // Read user's typed encoding. Otherwise use default encoding.
            if (ParsingUtilities.HasTwoParam(name, line))
            {
                // Second argument in quotes (encoding).
                currentEncoding = EncodingUtilities.dictStrEncoding[arguments[1]];
            }
            else
            {
                currentEncoding = defaultEncoding;
            }
        }
        public override bool ValidateParams(string line)
        {
            // Print command can have 2 or 3 options.
            try
            {
                if (!(ParsingUtilities.HasTwoParam(name, line) ||
                      ParsingUtilities.HasThreeParam(name, line)))
                {
                    return(false);
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            string[] arguments = ParsingUtilities.GetQuoteArguments(line);
            string   path      = PathTracker.CombineRelativePath(arguments[0]);

            // Check if file already exists.
            if (PathTracker.IsFilePathValid(path))
            {
                throw new InvalidPathException("FILE_ALREADY_EXISTS");
            }

            // Check if chosen encoding is correct.
            try
            {
                if (ParsingUtilities.HasThreeParam(name, line))
                {
                    if (!EncodingUtilities.dictStrEncoding.ContainsKey(arguments[2]))
                    {
                        throw new InvalidEncodingException();
                    }
                }
            }
            catch (RegexMatchTimeoutException)
            {
                return(false);
            }

            return(true);
        }