static void Main(string[] args) { if (args.Length == 0) { args = new[] { "the.log", "false" }; } if (args.Length == 1) { args = new[] { args[0], "false" }; } var logPath = args[0]; var waitForCancellation = bool.Parse(args[1]); using var consoleCancellationHandler = new ConsoleCancellation(); var disposable1 = new Disposable(() => { File.AppendAllText(logPath, "1"); }); //-V3114 var disposable2 = new Disposable(() => { File.AppendAllText(logPath, "2"); }); //-V3114 Console.WriteLine(disposable1.IsDisposed && disposable2.IsDisposed); // Ensure objects are not optimized away if (waitForCancellation) { consoleCancellationHandler.Wait(); } }
private static void Main(string[] args) { using var cancellation = new ConsoleCancellation(); var argumentIndex = 0; var username = ConsoleHelpers.GetOrReadArgument(argumentIndex++, "Username", args); var token = ConsoleHelpers.GetOrReadArgument(argumentIndex++, "Token", args); var appName = ConsoleHelpers.GetOrReadArgument(argumentIndex++, "App Name", args); var databaseFileName = ConsoleHelpers.GetOrReadArgument(argumentIndex++, "Database file name", args); var fileSetName = ConsoleHelpers.GetOrReadArgument(argumentIndex++, "File set name", args); var minimumInteractionIntervalStringInputInSeconds = ConsoleHelpers.GetOrReadArgument(argumentIndex, "Minimum interaction interval in seconds", args); var minimumInteractionInterval = TimeSpan.FromSeconds(Int32.Parse(minimumInteractionIntervalStringInputInSeconds)); var dbContext = new FileStorage(databaseFileName); Console.WriteLine($"Bot has been started. {Environment.NewLine}Press CTRL+C to close"); try { while (true) { var api = new GitHubStorage(username, token, appName); new IssueTracker(new List <ITrigger <Issue> > { new HelloWorldTrigger(api, dbContext, fileSetName), new OrganizationLastMonthActivityTrigger(api), new LastCommitActivityTrigger(api), new ProtectMainBranchTrigger(api), }, api).Start(cancellation.Token); new PullRequestTracker(new List <ITrigger <PullRequest> > { new MergeDependabotBumpsTrigger(api) }, api).Start(cancellation.Token); Thread.Sleep(minimumInteractionInterval); } } catch (Exception ex) { Console.WriteLine(ex.ToStringWithAllInnerExceptions()); } }