示例#1
0
def cli_issue_create(no_pretty=False,
                     organization=None,
                     project=None,
                     **issue_attributes):
    """Create a GitHub issue."""
    issue = Issue.from_dict(**issue_attributes)
    issue = issue.create(organization, project)
    print_command_result(issue.to_dict(), not no_pretty)
示例#2
0
def cli_issue_edit(no_pretty=False, organization=None, project=None, number=None, **issue_attributes):
    """Modify a GitHub issue."""
    _LOG.debug("Issue attributes: %s", issue_attributes)

    if all(val is None for val in issue_attributes.values()):
        raise ValueError("No attributes to edit")

    issue = IssueHandler(**issue_attributes).edit(organization, project, number)
    print_command_result(issue.to_dict(), not no_pretty)
示例#3
0
def cli_issues(organization=None, project=None, no_pretty=False, **issues_attributes):
    """List GitHub issues."""
    issues = IssuesHandler(**issues_attributes)
    _LOG.debug("Issues listing query: %s", issues)
    # TODO: split to two commands
    if project is None:
        reported_issues = issues.list_assigned_issues(organization)
    else:
        reported_issues = issues.list_issues(organization, project)
    print_command_result(list(map(lambda x: x.to_dict(), reported_issues)), not no_pretty)
示例#4
0
def cli_issue_edit(no_pretty=False,
                   organization=None,
                   project=None,
                   number=None,
                   **issue_attributes):
    """Modify a GitHub issue."""
    if all(val is None for val in issue_attributes.values()):
        raise UserInputError("No attributes to edit")

    # TODO: edit by number
    issue = Issue.edit(organization, project, number, issue_attributes)
    print_command_result(issue.to_dict(), not no_pretty)
示例#5
0
def cli_config(ctx,
               no_pretty=False,
               create=False,
               overwrite=False,
               path=None,
               no_print=False):
    """Manipulate with githubcap configuration."""
    if no_print and not create:
        _LOG.error("Nothing to do, exiting...")
        ctx.exit(1)

    if create:
        Configuration().write2file(path, overwrite=overwrite)

    if not no_print:
        print_command_result(Configuration().to_dict(), pretty=not no_pretty)
示例#6
0
def cli_issues(organization=None,
               project=None,
               no_pretty=False,
               **issues_query):
    """List GitHub issues."""
    if organization is None and project is None:
        reported_issues = Issue.list_assigned_issues(**issues_query)
    elif organization is not None and project is None:
        reported_issues = Issue.list_organization_issues(
            organization, **issues_query)
    elif organization is not None and project is not None:
        reported_issues = Issue.list_project_issues(organization, project,
                                                    **issues_query)
    else:
        raise UserInputError(
            "Organization has to be specified explicitly for project %r" %
            project)

    print_command_result(list(map(lambda x: x.to_dict(), reported_issues)),
                         not no_pretty)
示例#7
0
def cli_scrape(no_pretty=False, resources_dir=None, schemas_dir=None):
    result = scrape(resources_dir, schemas_dir)
    print_command_result(result, not no_pretty)
示例#8
0
def cli_issue(no_pretty=False, organization=None, project=None, number=None):
    """Retrieve a GitHub issue."""
    issue = IssueHandler.by_number(organization, project, number)
    print_command_result(issue.to_dict(), not no_pretty)
示例#9
0
def cli_issue_create(no_pretty=False, organization=None, project=None, **issue_attributes):
    """Create a GitHub issue."""
    _LOG.debug("Issue attributes: %s", issue_attributes)
    issue = IssueHandler(**issue_attributes).create(organization, project)
    print_command_result(issue.to_dict(), not no_pretty)