Пример #1
0
        private void FileMode()
        {
            bool autoName = Descender.Accept("-a", "--autoname");

            if (Descender.Accept("-s", "--singlefile"))
            {
                SingleFile();
            }
            else if (Descender.Accept("-a", "--autoname"))
            {
                autoName = true;
            }

            while (Descender.Accept("-i", "--input"))
            {
                string inFile = Descender.Keep();

                if (inFile == null)
                {
                    throw new Exception("Invalid input file.");
                }

                if (!File.Exists(inFile))
                {
                    throw new Exception("File \"" + inFile + "\" does not exist.");
                }

                Output.Inputs.Add(inFile);

                if (Descender.Accept("-o", "--output"))
                {
                    string outFile = Descender.Keep();

                    if (outFile == null)
                    {
                        throw new Exception("Invalid output file.");
                    }

                    Output.Outputs.Add(outFile);
                }
                else
                {
                    if (autoName)
                    {
                        Output.Outputs.Add(AutoName(inFile));
                    }
                    else
                    {
                        throw new Exception("All --input directives must be followed by a --output directive if the --autoname option is not set.");
                    }
                }

                if (Descender.CurrentToken != "-i" && Descender.CurrentToken != "--input" && Descender.CurrentToken != null)
                {
                    throw new Exception("Incorrect directive: " + Descender.CurrentToken);
                }
            }

            ExpectEnd();
        }
Пример #2
0
 private void ExpectEnd()
 {
     if (Descender.MoreTokens())
     {
         throw new Exception("Incorrect arguments.");
     }
 }
Пример #3
0
        private void OutputType()
        {
            if (Descender.Accept("-s", "--singlefile"))
            {
                SingleFile();
            }
            else if (Descender.Accept("-a", "--autoname"))
            {
                // Automatically name all the files.
                foreach (string file in Output.Inputs)
                {
                    string autoName = AutoName(file);

                    if (autoName == file)
                    {
                        throw new Exception("The input file \"" + file + "\" is invalid as it would have the same auto-name.");
                    }

                    Output.Outputs.Add(autoName);
                }
            }
            else
            {
                throw new Exception("You must specify either the --autoname or --singlefile option.");
            }

            ExpectEnd();
        }
Пример #4
0
        private void FolderMode()
        {
            bool         rootOnly = Descender.Accept("-r", "--rootonly");
            SearchOption option   = GetSearchOption(rootOnly);

            if (Descender.Accept("-i", "--indir"))
            {
                string inputDirectory = Descender.Keep();

                if (inputDirectory == null)
                {
                    throw new Exception("Invalid input directory.");
                }

                // Read the input directory.
                string[] files = Directory.GetFiles(inputDirectory, "*.joop", option);

                foreach (string file in files)
                {
                    Output.Inputs.Add(file);
                }

                // Figure out the output type.
                OutputType();
            }
            else
            {
                throw new Exception("The --indir parameter is required for directory mode.");
            }
        }
Пример #5
0
        private void SingleFile()
        {
            string outFile = Descender.Keep();

            if (outFile == null)
            {
                throw new Exception("Invalid output file.");
            }

            Output.Outputs.Add(outFile);
            Output.SingleFile = true;
        }
Пример #6
0
        public void Parse()
        {
            Output = new ParsingOutput();
            MSBuildErrors();

            if (Descender.Accept("-d", "--dirmode"))
            {
                FolderMode();
            }
            else if (Descender.Accept("-f", "--filemode"))
            {
                FileMode();
            }
            else
            {
                Output.PrintHelp = true;
            }
        }
Пример #7
0
 private void MSBuildErrors()
 {
     Output.MSBuildErrors = Descender.Accept("-m", "--msbuild");
 }