Skip to content

Add create issue command to CLI #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add create issue command to CLI #9

wants to merge 1 commit into from

Conversation

kaar
Copy link
Owner

@kaar kaar commented Sep 23, 2024

Add a new command create to the cmd_issue CLI group. This command
allows users to create issues with various options such as title,
description, team ID, label IDs, and assignee ID. The command also
supports output in JSON format.

Example usage:

linear issue create "New Issue" --description "Details" --team-id "team123"

In client.py, add a create_issue method to the User class to
handle the GraphQL mutation for creating issues. This method constructs
the mutation query and prints it for debugging purposes.

Example:

user.create_issue(
    title="New Issue",
    description="Details",
    team_id="team123",
    label_id=["label1", "label2"],
    assignee_id="assignee123"
)
  • The create_issue method currently returns an empty list and does not
    execute the GraphQL request. The line # data = gql_request(query)
    should be uncommented and properly implemented.
  • The return Issue.from_dict(data["data"]["createIssue"]["issue"])
    line is unreachable due to the preceding return [] statement. The
    first return statement should be removed.

Add a new command `create` to the `cmd_issue` CLI group. This command
allows users to create issues with various options such as title,
description, team ID, label IDs, and assignee ID. The command also
supports output in JSON format.

Example usage:
```sh
linear issue create "New Issue" --description "Details" --team-id "team123"
```

In `client.py`, add a `create_issue` method to the `User` class to
handle the GraphQL mutation for creating issues. This method constructs
the mutation query and prints it for debugging purposes.

Example:
```python
user.create_issue(
    title="New Issue",
    description="Details",
    team_id="team123",
    label_id=["label1", "label2"],
    assignee_id="assignee123"
)
```

- The `create_issue` method currently returns an empty list and does not
  execute the GraphQL request. The line `# data = gql_request(query)`
  should be uncommented and properly implemented.
- The `return Issue.from_dict(data["data"]["createIssue"]["issue"])`
  line is unreachable due to the preceding `return []` statement. The
  first return statement should be removed.
@kaar kaar requested a review from Copilot May 22, 2025 18:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new create command to the linear issue CLI and implements a stub in the client for creating issues via GraphQL.

  • Introduces User.create_issue in linear/client.py with a GraphQL mutation template.
  • Registers linear issue create command in linear/cli.py with options for title, description, team, labels, assignee, and JSON output.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
linear/client.py Added create_issue method stub with query template.
linear/cli.py Added cmd_issue.create command and option parsing.
Comments suppressed due to low confidence (1)

linear/cli.py:59

  • This new CLI command isn't covered by existing tests. Add unit or integration tests to verify linear issue create with various flag combinations and JSON vs. markdown output.
@cmd_issue.command("create")

title: str,
description: Optional[str] = None,
team_id: Optional[str] = None,
label_id: Optional[str] = None,
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label_id parameter is annotated as Optional[str] but used with json.dumps on a sequence; update the type to Optional[List[str]] (or appropriate iterable) to match its actual usage.

Suggested change
label_id: Optional[str] = None,
label_id: Optional[list[str]] = None,

Copilot uses AI. Check for mistakes.

Comment on lines +215 to +217
# data = gql_request(query)
print(query)
return []
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GraphQL request call is commented out, so the mutation is never executed. Uncomment and implement data = gql_request(query) before processing the response.

Suggested change
# data = gql_request(query)
print(query)
return []
data = gql_request(query)

Copilot uses AI. Check for mistakes.

Comment on lines +217 to +218
return []
return Issue.from_dict(data["data"]["createIssue"]["issue"])
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return [] prevents any real issue object from being returned and makes the subsequent Issue.from_dict unreachable. Remove the stub return so the actual response is returned.

Suggested change
return []
return Issue.from_dict(data["data"]["createIssue"]["issue"])
raise NotImplementedError("GraphQL request functionality is not yet implemented.")
# return Issue.from_dict(data["data"]["createIssue"]["issue"])

Copilot uses AI. Check for mistakes.

Comment on lines +180 to +186
mutation CreateIssue {
createIssue(input: {
title: "%s"
description: "%s"
teamId: "%s"
labelIds: %s
assigneeId: "%s"
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline string interpolation in GraphQL queries can lead to injection vulnerabilities. Switch to using GraphQL variables or ensure proper escaping of user input.

Suggested change
mutation CreateIssue {
createIssue(input: {
title: "%s"
description: "%s"
teamId: "%s"
labelIds: %s
assigneeId: "%s"
mutation CreateIssue($title: String!, $description: String, $teamId: String, $labelIds: [String!], $assigneeId: String) {
createIssue(input: {
title: $title
description: $description
teamId: $teamId
labelIds: $labelIds
assigneeId: $assigneeId

Copilot uses AI. Check for mistakes.

title: str,
description: Optional[str],
team_id: Optional[str],
label_id: Optional[str],
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI option --label-id is multiple=True, so it yields a tuple. Update the function signature to label_id: Tuple[str, ...] (or List[str]) instead of Optional[str].

Suggested change
label_id: Optional[str],
label_id: Tuple[str, ...],

Copilot uses AI. Check for mistakes.

json: bool,
):
"""
linear issue create <title> [--description <description>]
Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring only mentions title and --description, but the command now supports team, labels, assignee, and JSON flags. Update it to reflect all available options.

Suggested change
linear issue create <title> [--description <description>]
linear issue create --title <title> [--description <description>] [--team-id <team-id>]
[--label-id <label-id>] [--assignee-id <assignee-id>] [--json]
Options:
--title <title> The title of the issue (required).
--description <description> A detailed description of the issue (optional).
--team-id <team-id> The ID of the team to assign the issue to (optional).
--label-id <label-id> One or more label IDs to associate with the issue (optional).
--assignee-id <assignee-id> The ID of the assignee for the issue (optional).
--json Output the issue in JSON format (optional).

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant