コード例 #1
0
        static void Main(string[] args)
        {
            // Read args
            var ArgOptions = new ArgOptions();

            // Because ASCII ¯\_(ツ)_/¯
            PrintLogo();

            // Parse args
            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (!string.IsNullOrEmpty(ArgOptions.Launch) || !string.IsNullOrEmpty(ArgOptions.RealCmdLine) || !string.IsNullOrEmpty(ArgOptions.FakeCmdLine))
                {
                    SpawnTheThing(ArgOptions.Launch, ArgOptions.RealCmdLine, ArgOptions.FakeCmdLine);
                }
                else
                {
                    PrintHelp();
                }
            }
            else
            {
                PrintHelp();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: xtheorycrafter/Sharp-Suite
        static void Main(string[] args)
        {
            // Read args
            var ArgOptions = new ArgOptions();

            // Parse args
            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (string.IsNullOrEmpty(ArgOptions.Search) && !ArgOptions.List)
                {
                    Helper.PrintHelp();
                }
                else
                {
                    if (ArgOptions.List)
                    {
                        GetAPISet(String.Empty, true);
                    }
                    else
                    {
                        GetAPISet(ArgOptions.Search, false);
                    }
                }
            }
            else
            {
                Helper.PrintHelp();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: citizenmatt/StatLight
 public CommandLineExecutionEngine(ILogger logger, ArgOptions args)
     : this(logger, args,
         new StatLightConfigurationFactory(logger),
         runner => runner.Run(),
         new StatLightRunnerFactory(logger))
 {
 }
コード例 #4
0
        public static IArgOptions Parse(string[] args, out bool parsedOK)
        {
            var options = new ArgOptions();
            var parser  = new Fclp.FluentCommandLineParser <ArgOptions>();

            parser.Setup(arg => arg.Host).As('H', "host").SetDefault("127.0.0.1").WithDescription("host").Callback(arg => { options.Host = arg; Logger.DebugFormat("host = " + arg); });
            parser.Setup(arg => arg.Port).As('p', "port").Required().SetDefault(9111).WithDescription("port").Callback(arg => { options.Port = arg; Logger.DebugFormat("port = " + arg); });
            parser.Setup(arg => arg.SendInterval).As('s', "sendInterval").SetDefault(100).WithDescription("interval milliseconds").Callback(arg => { options.SendInterval = arg; Logger.DebugFormat("send interval = " + arg + " ms"); });
            parser.Setup(arg => arg.RunningSeconds).As('r', "runningSeconds").SetDefault(3600).WithDescription("running seconds").Callback(arg => { options.RunningSeconds = arg; Logger.DebugFormat("running seconds = " + arg + " s"); });
            parser.Setup(arg => arg.MessagesPerConnection).As('n', "messagesPerConnection").SetDefault(0).WithDescription("send message count per connection. 0 = no limit").Callback(arg => { options.MessagesPerConnection = arg; Logger.DebugFormat("messages per connection = " + arg); });
            parser.Setup(arg => arg.KeysPerConnection).As('n', "keysPerConnection").SetDefault(0).WithDescription("send message count per connection. 0 = no limit").Callback(arg => { options.KeysPerConnection = arg; Logger.DebugFormat("keys per connection = " + arg); });
            parser.Setup(arg => arg.QuitIfExceededAny).As('q', "quitIfExceeded").SetDefault(true).WithDescription("quit if exceed time or message-count").Callback(arg => { options.QuitIfExceededAny = arg; Logger.DebugFormat("quit if exceeded any condition = " + arg); });
            parser.Setup(arg => arg.MaxConnectTimes).As('q', "maxConnectTimes").SetDefault(0).WithDescription("quit if exceed time or message-count").Callback(arg => { options.MaxConnectTimes = arg; Logger.DebugFormat("quit if exceeded any condition = " + arg); });
            parser.Setup(arg => arg.PauseSecondsAtDrop).As('q', "pause seconds at each connection lost").SetDefault(0).WithDescription("pause seconds at each connection lost").Callback(arg => { options.PauseSecondsAtDrop = arg; Logger.DebugFormat("pause seconds at each connection lost = " + arg); });
            parser.SetupHelp("h", "help").Callback(text => Console.WriteLine(text));
            var result = parser.Parse(args);

            //Log(string.Format("ParserFluentArgs : p = {0}", p.ToString()));
            if (result.HasErrors || args.Length < 1)
            {
                parser.HelpOption.ShowHelp(parser.Options);
                parsedOK = false;
            }

            parsedOK = true;
            return(options);
        }
コード例 #5
0
ファイル: LinearTypeChecker.cs プロジェクト: tushetodorov/P
        private ISet <Variable> ProcessArgList(IEnumerable <IPExpr> arguments, ISet <Variable> unavailable,
                                               ArgOptions perm = ArgOptions.SwapAllowed)
        {
            var swapAllowed         = perm == ArgOptions.SwapAllowed;
            var remainingLinearRefs = new List <ILinearRef>();

            foreach (var argument in arguments)
            {
                if (argument is ILinearRef linearRef)
                {
                    if (linearRef.LinearType.Equals(LinearType.Swap) && !swapAllowed)
                    {
                        throw handler.InvalidSwap(linearRef, "swap not allowed in this context");
                    }

                    remainingLinearRefs.Add(linearRef);
                }
                else
                {
                    unavailable = ProcessExpr(unavailable, argument);
                }
            }

            return(remainingLinearRefs.Aggregate(unavailable, ProcessExpr));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: xtheorycrafter/Sharp-Suite
        static void Main(string[] args)
        {
            hSupp.PrintBanner();
            var ArgOptions = new ArgOptions();

            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (ArgOptions.Load || ArgOptions.Unload || !String.IsNullOrEmpty(ArgOptions.VirtToPhys))
                {
                    if (ArgOptions.Load)
                    {
                        Wrapper.LoadMsIo();
                    }
                    else if (ArgOptions.Unload)
                    {
                        Wrapper.UnLoadMsIo();
                    }
                    else
                    {
                        Wrapper.TranslateVirtToPhys((IntPtr)Convert.ToInt64(ArgOptions.VirtToPhys, 16));
                    }
                }
                else
                {
                    hSupp.GetHelp();
                }
            }
            else
            {
                hSupp.GetHelp();
            }
        }
コード例 #7
0
        public static IArgOptions Parse(string[] args, out bool parsedOK)
        {
            var options = new ArgOptions();
            var parser  = new CommandLine.Parser();

            parsedOK = parser.ParseArguments(args, options);
            return(options);
        }
コード例 #8
0
            public void When_overriding_setting_MaxWaitTimeAllowedBeforeCommunicationErrorSent()
            {
                ArgOptions command = "--OverrideSetting:MaxWaitTimeAllowedBeforeCommunicationErrorSent=00:00:20".ToArgOptions();

                command.OverriddenSettings.Count().ShouldEqual(1);
                command.OverriddenSettings.First().Key.ShouldEqual("MaxWaitTimeAllowedBeforeCommunicationErrorSent");
                command.OverriddenSettings.First().Value.ShouldEqual("00:00:20");
            }
コード例 #9
0
ファイル: Program.cs プロジェクト: citizenmatt/StatLight
 internal CommandLineExecutionEngine(ILogger logger, ArgOptions args, IStatLightConfigurationFactory statLightConfigurationFactory, Func<IRunner, TestReport> runnerFunc, IStatLightRunnerFactory statLightRunnerFactory)
 {
     _logger = logger;
     _statLightRunnerFactory = statLightRunnerFactory;
     _options = args;
     _statLightConfigurationFactory = statLightConfigurationFactory;
     _runnerFunc = runnerFunc;
 }
コード例 #10
0
 public DynamicUpdateClient(ArgOptions options)
 {
     ClientOptions = options;
     if (options.Timeout > 0)
     {
         defaultWaitTimeout = options.Timeout;
     }
     SetupDriver();
 }
コード例 #11
0
            public void Should_be_able_to_set_a_dll_to_test()
            {
                ArgOptions command = "-d:somePath.dll".ToArgOptions();

                command.XapPaths.Count.ShouldEqual(0);

                command.Dlls.Count.ShouldEqual(1);
                command.Dlls.First().ShouldEqual("somePath.dll");
            }
コード例 #12
0
            public void geometry_specified(string option, BrowserWindowState expectedBrowserWindowState, int expectedWidth, int expectedHeight)
            {
                WindowGeometry windowGeometry = ArgOptions.ParseWindowGeometry(option);

                windowGeometry.ShouldNotBeNull();

                windowGeometry.State.ShouldEqual(expectedBrowserWindowState);
                windowGeometry.Size.Width  = expectedWidth;
                windowGeometry.Size.Height = expectedHeight;
            }
コード例 #13
0
ファイル: Program.cs プロジェクト: pietermyb/dottechduc
        private static void Main(string[] args)
        {
            Parser.Default.ParseArguments <ArgOptions>(args)
            .WithParsed <ArgOptions>(o =>
            {
                Options = o;
                if (o.Verbose)
                {
                    Console.WriteLine("Verbose output enabled.");
                }

                RunDuc();
            });
        }
コード例 #14
0
            public void Should_run_the_OneTimeRunner()
            {
                ArgOptions argOptions = "-x=test.xap".ToArgOptions();
                var        mockConfiugrationFactory   = new Mock <IStatLightConfigurationFactory>();
                var        mockStatLightRunnerFactory = new Mock <IStatLightRunnerFactory>();

                mockStatLightRunnerFactory
                .Setup(s => s.CreateOnetimeConsoleRunner(It.IsAny <StatLightConfiguration>()))
                .Returns(new Mock <IRunner>().Object);
                Func <IRunner, TestReport> f = runner => new TestReport(argOptions.XapPaths.First());
                var engine = new CommandLineExecutionEngine(TestLogger, argOptions, mockConfiugrationFactory.Object, f, mockStatLightRunnerFactory.Object);

                engine.Run();

                mockStatLightRunnerFactory.Verify(x => x.CreateOnetimeConsoleRunner(It.IsAny <StatLightConfiguration>()));
            }
コード例 #15
0
        /// <summary>
        ///     Only constructor for the class.
        /// </summary>
        /// <remarks>
        ///     Logs into Innovator and sets the class fields/properties relating to Aras and the command line options.
        /// </remarks>
        /// <param name="options">The <see cref="ArgOptions" /> the program was started with.</param>
        internal ArasExport(ArgOptions options)
        {
            Console.WriteLine("Establishing server connection...");
            var login = new ArasLogin(options.Url, options.Database, options.Login, options.Password);

            Console.WriteLine("Server connection established.");

            _arasLogin           = login;
            _myInnovator         = login.Innovator;
            _prefixList          = options.Prefixes?.ToList();
            _prefixWasGiven      = _prefixList?.Any() ?? false;
            _packageName         = options.PackageDefinition;
            _doConsiderPackage   = !string.IsNullOrWhiteSpace(_packageName);
            _useWiderSearch      = options.UseWiderSearch;
            _excludeDefaultProps = options.ExcludeDefaultProps;
        }
コード例 #16
0
        static void Main(string[] args)
        {
            // Read args
            var ArgOptions = new ArgOptions();

            // Get that ASCII..
            Mace.PrintBanner();

            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (!string.IsNullOrEmpty(ArgOptions.List) || !string.IsNullOrEmpty(ArgOptions.Set))
                {
                    if (!string.IsNullOrEmpty(ArgOptions.List))
                    {
                        // Read timestamp information
                        Mace.GetTime(ArgOptions.List);
                    }
                    else if (!string.IsNullOrEmpty(ArgOptions.Duplicate))
                    {
                        DuplicateObjectFileTime(ArgOptions.Set, ArgOptions.Duplicate);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(ArgOptions.Time))
                        {
                            // Write timestamp information
                            SetObjectFileTime(ArgOptions.Set, ArgOptions.Time, ArgOptions.Create, ArgOptions.Access, ArgOptions.Write);
                        }
                        else
                        {
                            Console.WriteLine("[!] Missing DateTime string (-t)..");
                            return;
                        }
                    }
                }
                else
                {
                    Mace.PrintHelp();
                }
            }
            else
            {
                Mace.PrintHelp();
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: xforcered/Dendrobate
        static void Main(string[] args)
        {
            // Because ASCII
            hBates.getASCII();

            // Parse args
            var ArgOptions = new ArgOptions();

            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (ArgOptions.bHelp || args.Length == 0)
                {
                    hBates.getHelp();
                }
                else
                {
                    if (ArgOptions.bKill)
                    {
                        Boolean bSent = hBates.passControlCodeByPipe();
                        if (bSent)
                        {
                            Console.WriteLine("\n[+] Dendron client un-hooking..");
                        }
                        else
                        {
                            Console.WriteLine("\n[!] Failed to talk to Dendron client..");
                        }
                        return;
                    }
                    else if (ArgOptions.iListen != 0)
                    {
                        hBates.ListenNamedPipe(ArgOptions.iListen);
                        return;
                    }
                    else
                    {
                        hBates.getHelp();
                    }
                }
            }
            else
            {
                hBates.getHelp();
            }
        }
コード例 #18
0
ファイル: AnalysisEngine.cs プロジェクト: JerryBian/dff
        public async Task ExecuteAsync(ArgOptions options)
        {
            var filesMarkedAsDuplicate = new HashSet <string>();

            // EnumerateFiles API will skip deleted one during iteration, but not for new added file.
            // Usually we don't have the new added case here, so it's safe.
            // However, if the input directory is root we may put duplicates directory to same too.
            // Anyway, we are good here.
            foreach (var file1 in Directory.EnumerateFiles(options.InputFolder, "*", SearchOption.AllDirectories))
            {
                if (filesMarkedAsDuplicate.Contains(file1))
                {
                    continue; // This file already marked as duplicate in previous analysis
                }

                var sameFiles = new List <string> {
                    file1
                };                                        // always feed file1 as one duplicate temporary
                foreach (var file2 in Directory.EnumerateFiles(options.InputFolder, "*",
                                                               SearchOption.AllDirectories))
                {
                    if (filesMarkedAsDuplicate.Contains(file2))
                    {
                        continue; // This file already marked as duplicate in previous analysis
                    }

                    if (await AreFilesEqualAsync(file1, file2))
                    {
                        sameFiles.Add(file2);
                        filesMarkedAsDuplicate.Add(file2);
                    }
                }

                if (sameFiles.Count > 1) // We have duplicates
                {
                    _fileManager.ProcessDuplicateFiles(options.InputFolder, sameFiles);
                    filesMarkedAsDuplicate.Add(file1);
                }
            }
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: whmacmac/Sharp-Suite
        static void Main(string[] args)
        {
            // Read args
            var ArgOptions = new ArgOptions();

            // Parse args
            if (CommandLineParser.Default.ParseArguments(args, ArgOptions))
            {
                if (!string.IsNullOrEmpty(ArgOptions.Path) || !string.IsNullOrEmpty(ArgOptions.Key) || !string.IsNullOrEmpty(ArgOptions.Out))
                {
                    CreateTemplate(ArgOptions.Path, ArgOptions.Key, ArgOptions.Out);
                }
                else
                {
                    Console.WriteLine("[!] Failed to provide args (-p|-Path & -k|-Key  & -o|-Out)");
                }
            }
            else
            {
                Console.WriteLine("[!] Failed to provide args (-p|-Path & -k|-Key  & -o|-Out)");
            }
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: brumfb/StatLight
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Console.WriteLine(e.ExceptionObject);
            };

            PrintNameVersionAndCopyright();

            using (var consoleIconSwapper = new ConsoleIconSwapper())
            {
                consoleIconSwapper.ShowConsoleIcon(CoreResources.FavIcon);

                try
                {
                    var options = new ArgOptions(args);

                    if (options.ShowHelp)
                    {
                        ArgOptions.ShowHelpMessage(Console.Out, options);
                        return;
                    }

                    if (!options.XapPaths.Any() && !options.Dlls.Any())
                    {
                        throw new StatLightException("No xap or silverlight dll's specified.");
                    }

                    var inputOptions = new InputOptions()
                        .SetWindowGeometry(options.WindowGeometry)
                        .SetUseRemoteTestPage(options.UseRemoteTestPage)
                        .SetMethodsToTest(options.MethodsToTest)
                        .SetMicrosoftTestingFrameworkVersion(options.MicrosoftTestingFrameworkVersion)
                        .SetTagFilters(options.TagFilters)
                        .SetUnitTestProviderType(options.UnitTestProviderType)
                        .SetNumberOfBrowserHosts(options.NumberOfBrowserHosts)
                        .SetQueryString(options.QueryString)
                        .SetWebBrowserType(options.WebBrowserType)
                        .SetForceBrowserStart(options.ForceBrowserStart)
                        .SetXapPaths(options.XapPaths)
                        .SetDllPaths(options.Dlls)
                        .SetReportOutputPath(options.XmlReportOutputPath)
                        .SetReportOutputFileType(options.ReportOutputFileType)
                        .SetContinuousIntegrationMode(options.ContinuousIntegrationMode)
                        .SetOutputForTeamCity(options.OutputForTeamCity)
                        .SetStartWebServerOnly(options.StartWebServerOnly)
                        .SetIsRequestingDebug(options.IsRequestingDebug)
                        ;

                    TestReportCollection testReports = null;

                    try
                    {
                        TinyIoCContainer ioc = BootStrapper.Initialize(inputOptions);

                        var commandLineExecutionEngine = ioc.Resolve<RunnerExecutionEngine>();

                        testReports = commandLineExecutionEngine.Run();
                    }
                    catch (TinyIoCResolutionException tinyIoCResolutionException)
                    {
                        if (options.IsRequestingDebug)
                        {
                            throw;
                        }

                        throw ResolveNonTinyIocException(tinyIoCResolutionException);
                    }

                    if (testReports.FinalResult == RunCompletedState.Failure)
                        Environment.ExitCode = ExitFailed;
                    else
                        Environment.ExitCode = ExitSucceeded;

                }
                catch (AddressAccessDeniedException addressAccessDeniedException)
                {
                    Environment.ExitCode = ExitFailed;
                    var helpMessage = @"
            Cannot run StatLight. The current account does not have the correct privilages.

            Exception:
            {0}

            Try: (the following two steps that should allow StatLight to start a web server on the requested port)
             1. Run cmd.exe as Administrator.
             2. Enter the following command in the command prompt.
              netsh http add urlacl url=http://+:8887/ user=DOMAIN\user
            ".FormatWith(addressAccessDeniedException.Message);

                    WriteErrorToConsole(helpMessage, "Error");
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    HandleKnownError(fileNotFoundException);
                }
                catch (StatLightException statLightException)
                {
                    HandleKnownError(statLightException);
                }

                catch (Exception exception)
                {
                    HandleUnknownError(exception);
                }
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: citizenmatt/StatLight
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
                                                              {
                                                                  Console.WriteLine(e.ExceptionObject);
                                                              };
            PrintNameVersionAndCopyright();

            ArgOptions options;

            using (var consoleIconSwapper = new ConsoleIconSwapper())
            {
                consoleIconSwapper.ShowConsoleIcon(CoreResources.FavIcon);

                try
                {
                    options = new ArgOptions(args);

                    if (options.ShowHelp)
                    {
                        ArgOptions.ShowHelpMessage(Console.Out, options);
                        return;
                    }

                    if (!options.XapPaths.Any() && !options.Dlls.Any())
                    {
                        throw new StatLightException("No xap or silverlight dll's specified.");
                    }

                    ILogger logger = GetLogger(options.IsRequestingDebug);

                    var commandLineExecutionEngine = new CommandLineExecutionEngine(logger, options);
                    TestReportCollection testReports = commandLineExecutionEngine.Run();

                    if (testReports.FinalResult == RunCompletedState.Failure)
                        Environment.ExitCode = ExitFailed;
                    else
                        Environment.ExitCode = ExitSucceeded;

                }
                catch (AddressAccessDeniedException addressAccessDeniedException)
                {
                    Environment.ExitCode = ExitFailed;
                    var helpMessage = @"
            Cannot run StatLight. The current account does not have the correct privilages.

            Exception:
            {0}

            Try: (the following two steps that should allow StatLight to start a web server on the requested port)
             1. Run cmd.exe as Administrator.
             2. Enter the following command in the command prompt.
              netsh http add urlacl url=http://+:8887/ user=DOMAIN\user
            ".FormatWith(addressAccessDeniedException.Message);

                    WriteErrorToConsole(helpMessage, "Error");
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    HandleKnownError(fileNotFoundException);
                }
                catch (StatLightException statLightException)
                {
                    HandleKnownError(statLightException);
                }

                catch (Exception exception)
                {
                    HandleUnknownError(exception);
                }
            }
        }