public static string Authenticate(this JiraSoapServiceClient client, Context context) { Argument.IsNotNull(() => client); Argument.IsNotNull(() => context); return client.login(context.UserName, context.Password); }
protected override void ExecuteWithContext(Context context) { // Note: we need a different instance of jira because it caches results var createVersionJira = CreateJira(context); _versionService.CreateVersion(createVersionJira, context.Project, context.Version); var releaseVersionJira = CreateJira(context); _versionService.ReleaseVersion(releaseVersionJira, context.Project, context.Version); }
protected override void ValidateContext(Context context) { if (string.IsNullOrEmpty(context.Project)) { Log.ErrorAndThrowException<JiraCliException>("Project is missing"); } if (string.IsNullOrEmpty(context.Version)) { Log.ErrorAndThrowException<JiraCliException>("Version is missing"); } }
public async Task<bool> Execute(Context context) { Argument.IsNotNull(() => context); try { await Task.Factory.StartNew(() => ExecuteWithContext(context)); return true; } catch (Exception ex) { Log.Error(ex); return false; } }
protected Jira CreateJira(Context context) { Argument.IsNotNull(() => context); return new Jira(context.JiraUrl, context.UserName, context.Password); }
protected abstract void ExecuteWithContext(Context context);
protected abstract void ValidateContext(Context context);
public void Validate(Context context) { context.ValidateContext(); ValidateContext(context); }
protected override void ExecuteWithContext(Context context) { var jira = CreateJira(context); _versionService.ReleaseVersion(jira, context.Project, context.Version); }
public static Context ParseArguments(List<string> commandLineArguments) { var context = new Context(); if (commandLineArguments.Count == 0) { Log.ErrorAndThrowException<JiraCliException>("Invalid number of arguments"); } var firstArgument = commandLineArguments.First(); if (IsHelp(firstArgument)) { context.IsHelp = true; return context; } if (commandLineArguments.Count < 2) { Log.ErrorAndThrowException<JiraCliException>("Invalid number of arguments"); } var namedArguments = commandLineArguments.ToList(); EnsureArgumentsEvenCount(commandLineArguments, namedArguments); for (var index = 0; index < namedArguments.Count; index = index + 2) { var name = namedArguments[index]; var value = namedArguments[index + 1]; if (IsSwitch("l", name)) { context.LogFile = value; continue; } if (IsSwitch("user", name)) { context.UserName = value; continue; } if (IsSwitch("pw", name)) { context.Password = value; continue; } if (IsSwitch("url", name)) { context.JiraUrl = value; continue; } if (IsSwitch("action", name)) { context.Action = value; continue; } if (IsSwitch("project", name)) { context.Project = value; continue; } if (IsSwitch("version", name)) { context.Version = value; continue; } //if (IsSwitch("ci", name)) //{ // bool isCi; // bool.TryParse(value, out isCi); // context.IsCi = isCi; // continue; //} Log.ErrorAndThrowException<JiraCliException>("Could not parse command line parameter '{0}'.", name); } return context; }