예제 #1
0
        public async Task Browse(BrowseParameters parameters)
        {
            var issuesResult = await _issuesFacade.ListIssues(new ListIssuesParameters(parameters.Project)
            {
                IssuesIds = new[] { parameters.IssueId }
            });

            if (issuesResult.IsFailure)
            {
                _outputPresenter.ShowError("Failed to browse to issue", issuesResult.Error);
                return;
            }

            var firstIssue = issuesResult.Value.FirstOrDefault();

            if (firstIssue == null)
            {
                _outputPresenter.ShowMessage($"Issue #{parameters.IssueId} was not found in project {parameters.Project}");
                return;
            }

            try
            {
                _browser.Open(firstIssue.WebUrl);
            }
            catch (Win32Exception ex)
            {
                _outputPresenter.ShowError($"Failed to open {firstIssue.WebUrl}: {ex}");
            }
        }
예제 #2
0
        public async Task CreateIssue(CreateIssueParameters parameters)
        {
            var issueResult = await _gitLabFacade.CreateIssue(parameters);

            if (issueResult.IsFailure)
            {
                _presenter.ShowError("Failed to create issue", issueResult.Error);
                return;
            }

            _presenter.ShowSuccess($"Successfully created issue #{issueResult.Value}");
        }
예제 #3
0
        public async Task CreateMergeRequest(CreateMergeRequestParameters parameters)
        {
            var mergeRequestResult = await _gitLabFacade.CreateMergeRequest(parameters);

            if (mergeRequestResult.IsFailure)
            {
                _presenter.ShowError("Failed to create merge request", mergeRequestResult.Error);
                return;
            }

            _presenter.ShowSuccess($"Successfully created merge request #{mergeRequestResult.Value}");
        }
예제 #4
0
        public async Task <int> Launch(string[] args)
        {
            try
            {
                IVisitableOption visitable = _parser.Parse(args);
                if (visitable == null)
                {
                    return(ExitCode.InvalidArguments);
                }

                await visitable.Accept(_optionsVisitor);
            }
            catch (Exception ex)
            {
                _outputPresenter.ShowError("Unexpected error has occured", ex.ToString());
                return(ExitCode.UnexpectedFailure);
            }
            finally
            {
                WaitForInput();
            }

            return(ExitCode.Success);
        }
예제 #5
0
 private void ShowError(Result result)
 => _outputPresenter.ShowError(result.Error);