コード例 #1
0
        static int Main(string[] args)
        {
            bool   err                      = false;
            bool   verbose                  = true;
            bool   report2stdout            = false;
            string reportDir                = null;
            ReportFileDestination rfd       = ReportFileDestination.UserDesktop;
            List <string>         sFileList = new List <string>();
            ValidatorParameters   vp        = new ValidatorParameters();

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

            if (args[0].EndsWith(".py"))
            {
                // Not try/catch.
                EmbeddedIronPython.RunScriptWithArgs(args);
                return(0);
            }

            vp.SetRasterTesting();
            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] || "+all-tables" == args[i])
                {
                    vp.SetAllTables();
                }
                else if ("-only-tables" == args[i])
                {
                    vp.ClearTables();
                }
                else if ("-quiet" == args[i])
                {
                    verbose = false;
                }
                else if ("-stdout" == args[i] || "-report-stdout" == args[i])
                {
                    verbose       = false;
                    report2stdout = true;
                    rfd           = ReportFileDestination.TempFiles;
                }
                else if ("-test-parms" == args[i])
                {
                    i++;
                    try
                    {
                        vp = (ValidatorParameters)EmbeddedIronPython.RunPythonMethod(args[i], "validation_parameters", "GetValue");
                    }
                    catch (Exception e)
                    {
                        ErrOut("Setting -test-parms failure: " + e.Message);
                        err = true;
                    }
                }
                else if ("+raster-tests" == args[i])
                {
                    // default
                }
                else if ("-no-raster-tests" == args[i])
                {
                    vp.SetNoRasterTesting();
                }
                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 if ("-temporary-reports" == args[i])
                {
                    rfd = ReportFileDestination.TempFiles;
                }
                else if ("-version" == args[i])
                {
                    Console.WriteLine("Version: {0}", version);
                    return(0); /* terminates success */
                }
                else
                {
                    ErrOut("Unknown argument: \"" + args[i] + "\"");
                    err = true;
                }
            }
            if (err)
            {
                Usage();
                return(1);
            }

            CmdLineInterface cmd = new
                                   CmdLineInterface(vp, sFileList.ToArray(), rfd, false,
                                                    reportDir, verbose, report2stdout);

            return(cmd.DoIt());
        }
コード例 #2
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());
        }
コード例 #3
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();
        }
コード例 #4
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();
        }