Exemplo n.º 1
0
        static int Main( string[] args )
        {
            bool err = false;
            bool verbose = true;
            string reportDir = null;
            ReportFileDestination rfd = ReportFileDestination.TempFiles;
            List<string> sFileList = new List<string>();
            ValidatorParameters vp = new ValidatorParameters();

            if (args.Length == 0) {
                Usage();
                return 0;
            }

            for ( int i = 0; i < args.Length; i++ ) {
                if ( "-file" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        sFileList.Add( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "+table" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        vp.AddTable( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-table" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        int n = vp.RemoveTableFromList( args[i] );
                        if ( 0 == n ) {
                            ErrOut( "Table \"" + args[i] + "\" not found" );
                            err = true;
                        }
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-all-tables" == args[i] ) {
                    vp.SetAllTables();
                }
                else if ( "-only-tables" == args[i] ) {
                    vp.ClearTables();
                }
                else if ( "-quiet" == args[i] ) {
                    verbose = false;
                }
                else if ( "+raster-tests" == args[i] ) {
                    vp.SetRasterTesting();
                }
                else if ( "-report-dir" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        reportDir = args[i];
                        rfd = ReportFileDestination.FixedDir;
                        // Try writing to the directory to see if it works.
                        using (FileStream fs = File.Create(
                                                           Path.Combine(
                                                                        reportDir,
                                                                        Path.GetRandomFileName()
                                                                        ),
                                                           1, // bufferSize
                                                           FileOptions.DeleteOnClose)
                               )
                        { };
                        // exception should throw & abort on failure
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }

                }
                else if ( "-report-in-font-dir" == args[i] ) {
                    rfd = ReportFileDestination.SameDirAsFont;
                }
                else {
                    ErrOut( "Unknown argument: \"" + args[i] + "\"" );
                    err = true;
                }
            }
            if ( err ) {
                Usage();
                return 1;
            }

            CmdLineInterface cmd = new
                CmdLineInterface( vp, sFileList.ToArray(), rfd, false,
                                  reportDir , verbose);
            return cmd.DoIt();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                try {
                FreeConsole();
                } catch (Exception e) when ( e is EntryPointNotFoundException || e is DllNotFoundException ) {
                    // FreeConsole() is neither available nor relevant
                    // on non-windows.
                }
                Application.Run(new Form1());
                return ;
            }

            bool err = false;
            string reportDir = null;
            ReportFileDestination rfd = ReportFileDestination.UserDesktop;
            List<string> sFileList = new List<string>();
            ValidatorParameters vp = new ValidatorParameters();

            int i,j;

            for (i = 0; i < args.Length; i++)
            {
                if ("-file" == args[i])
                {
                    j = i + 1;
                    if (j == args.Length)
                    {
                        ErrOut("Argument required for \"" + args[j-1] + "\"");
                        err = true;
                        break;
                    }

                    for (;j < args.Length; j++)
                    {
                        if (args[j][0] == '-' || args[j][0] == '+')
                        {
                            j--;
                            break;
                        }
                        sFileList.Add(args[j]);
                    }

                    if (j == i)
                    {
                        ErrOut("Argument required for \"" + args[i] + "\"");
                        err = true;
                        break;
                    }
                    i = j;

                }
                else if ("+table" == args[i])
                {

                    j = i + 1;
                    if (j == args.Length)
                    {
                        ErrOut("Argument required for \"" + args[j-1] + "\"");
                        err = true;
                        break;
                    }

                    for (; j < args.Length; j++)
                    {
                        if (args[j][0] == '-' || args[j][0] == '+')
                        {
                            j--;
                            break;
                        }
                        vp.AddTable(args[j]);
                    }

                    if (j == i)
                    {
                        ErrOut("Argument required for \"" + args[i] + "\"");
                        err = true;
                        break;
                    }

                    i = j;

                }
                else if ("-table" == args[i])
                {
                    j = i + 1;
                    if (j == args.Length)
                    {
                        ErrOut("Argument required for \"" + args[j - 1] + "\"");
                        err = true;
                        break;
                    }

                    for (; j < args.Length; j++)
                    {
                        if (args[j][0] == '-' || args[j][0] == '+')
                        {
                            j--;
                            break;
                        }
                        vp.RemoveTableFromList(args[j]);
                    }

                    if (j == i)
                    {
                        ErrOut("Argument required for \"" + args[i] + "\"");
                        err = true;
                        break;
                    }

                    i = j;

                }
                else if ("-all-tables" == args[i])
                {
                    vp.SetAllTables();
                }
                else if ("-only-tables" == args[i])
                {
                    vp.ClearTables();
                }
                else if ("-report-dir" == args[i])
                {
                    i++;
                    if (i < args.Length)
                    {
                        reportDir = args[i];
                        rfd = ReportFileDestination.FixedDir;
                    }
                    else
                    {
                        ErrOut("Argument required for \"" + args[i - 1] + "\"");
                        err = true;
                    }

                }
                else if ("-report-in-font-dir" == args[i])
                {
                    rfd = ReportFileDestination.SameDirAsFont;
                }
                else if ( "-temporary-reports" == args[i] ) {
                    rfd = ReportFileDestination.TempFiles;
                }
                else
                {
                    ErrOut("Unknown argument: \"" + args[i] + "\"");
                    err = true;
                }
            }
            if (err)
            {
                Usage();
                return ;
            }

            //Ready to run
            Validator v = new Validator();
            vp.SetupValidator(v);

            Program p = new Program();
            p.m_ReportFileDestination = rfd;
            p.m_sReportFixedDir = reportDir;

            Driver drv = new Driver(p);
            drv.RunValidation(v, sFileList.ToArray());
        }
Exemplo n.º 3
0
        static int Main( string[] args )
        {
            bool err = false;
            string reportDir = null;
            ReportFileDestination rfd = ReportFileDestination.TempFiles;
            List<string> sFileList = new List<string>();
            ValidatorParameters vp = new ValidatorParameters();
            
            if (args.Length == 0) {
                Usage();
                return 0;
            }

            for ( int i = 0; i < args.Length; i++ ) {
                if ( "-file" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        sFileList.Add( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "+table" == args[i] ) {
                    if ( i < args.Length ) {
                        vp.AddTable( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-table" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        int n = vp.RemoveTableFromList( args[i] );
                        if ( 0 == n ) {
                            ErrOut( "Table \"" + args[i] + "\" not found" );
                            err = true;
                        }
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-all-tables" == args[i] ) {
                    vp.SetAllTables();
                }
                else if ( "-only-tables" == args[i] ) {
                    vp.ClearTables();
                }
                else if ( "-report-dir" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        reportDir = args[i];
                        rfd = ReportFileDestination.FixedDir;
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                    
                }
                else if ( "-report-in-font-dir" == args[i] ) {
                    rfd = ReportFileDestination.SameDirAsFont;
                }
                else {
                    ErrOut( "Unknown argument: \"" + args[i] + "\"" );
                    err = true;
                }
            }
            if ( err ) {
                Usage();
                return 1;
            }

            CmdLineInterface cmd = new 
                CmdLineInterface( vp, sFileList.ToArray(), rfd, false, 
                                  reportDir );
            return cmd.DoIt();
        }