Esempio n. 1
0
 public void RunInteractiveConfigurator(CommandLineOptions options)
 {
     if (string.IsNullOrWhiteSpace(options.Username)) options.Username = GetUsername();
     if (string.IsNullOrWhiteSpace(options.Password)) options.Password = GetPassword();
     if (string.IsNullOrWhiteSpace(options.Repo)) options.Repo = GetRepo();
     _installer = _installer ?? new GitHubHookInstaller(options.Username, options.Password);
     if (string.IsNullOrWhiteSpace(options.HookId)) options.HookId = GetHookId(options);
 }
Esempio n. 2
0
 private static void Main(string[] args)
 {
     var options = new CommandLineOptions();
     if (Parser.Default.ParseArguments(args, options))
     {
         var configurator = new GitHubConfigurator();
         if (options.Interactive)
             configurator.RunInteractiveConfigurator(options);
         configurator.ConfigureHooks(options);
         if (options.Interactive)
         {
             Console.WriteLine("Hook successfully configured - enter to exit.");
             Console.ReadLine();
         }
     }
 }
Esempio n. 3
0
 public void ConfigureHooks(CommandLineOptions options)
 {
     _installer = _installer ?? new GitHubHookInstaller(options.Username, options.Password);
     _installer.ConfigureHook(options.HookId, options.Username, options.Repo);
 }
Esempio n. 4
0
 private string GetHookId(CommandLineOptions options)
 {
     string hookid = null;
     List<GitHubHookInstaller.GitHubHookResponse> hooks = _installer.GetAllGitHubHooks(options.Username,
                                                                                       options.Repo);
     for (int i = 0; i < hooks.Count; i++)
     {
         Console.WriteLine(string.Format("{0}: {1} {2} ({3})", i + 1, hooks[i].name, hooks[i].config.url,
                                         hooks[i].id));
     }
     Console.WriteLine("Please select which hook to use (enter the first number on the line):");
     for (int i = 0; string.IsNullOrWhiteSpace(hookid) && i < 3; i++)
     {
         string line = Console.ReadLine();
         int index;
         if (int.TryParse(line, out index) && index > 0 && index <= hooks.Count)
         {
             hookid = hooks[index - 1].id.ToString();
         }
     }
     return hookid;
 }