コード例 #1
0
        public static string Authenticate(this JiraSoapServiceClient client, Context context)
        {
            Argument.IsNotNull(() => client);
            Argument.IsNotNull(() => context);

            return client.login(context.UserName, context.Password);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
ファイル: ActionBase.cs プロジェクト: gitter-badger/JiraCli
        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;
            }
        }
コード例 #5
0
ファイル: ActionBase.cs プロジェクト: gitter-badger/JiraCli
        protected Jira CreateJira(Context context)
        {
            Argument.IsNotNull(() => context);

            return new Jira(context.JiraUrl, context.UserName, context.Password);
        }
コード例 #6
0
ファイル: ActionBase.cs プロジェクト: gitter-badger/JiraCli
 protected abstract void ExecuteWithContext(Context context);
コード例 #7
0
ファイル: ActionBase.cs プロジェクト: gitter-badger/JiraCli
 protected abstract void ValidateContext(Context context);
コード例 #8
0
ファイル: ActionBase.cs プロジェクト: gitter-badger/JiraCli
        public void Validate(Context context)
        {
            context.ValidateContext();

            ValidateContext(context);
        }
コード例 #9
0
        protected override void ExecuteWithContext(Context context)
        {
            var jira = CreateJira(context);

            _versionService.ReleaseVersion(jira, context.Project, context.Version);
        }
コード例 #10
0
        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;
        }