-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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
inlinear/client.py
with a GraphQL mutation template. - Registers
linear issue create
command inlinear/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, |
There was a problem hiding this comment.
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.
label_id: Optional[str] = None, | |
label_id: Optional[list[str]] = None, |
Copilot uses AI. Check for mistakes.
# data = gql_request(query) | ||
print(query) | ||
return [] |
There was a problem hiding this comment.
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.
# data = gql_request(query) | |
print(query) | |
return [] | |
data = gql_request(query) |
Copilot uses AI. Check for mistakes.
return [] | ||
return Issue.from_dict(data["data"]["createIssue"]["issue"]) |
There was a problem hiding this comment.
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.
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.
mutation CreateIssue { | ||
createIssue(input: { | ||
title: "%s" | ||
description: "%s" | ||
teamId: "%s" | ||
labelIds: %s | ||
assigneeId: "%s" |
There was a problem hiding this comment.
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.
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], |
There was a problem hiding this comment.
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]
.
label_id: Optional[str], | |
label_id: Tuple[str, ...], |
Copilot uses AI. Check for mistakes.
json: bool, | ||
): | ||
""" | ||
linear issue create <title> [--description <description>] |
There was a problem hiding this comment.
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.
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.
Add a new command
create
to thecmd_issue
CLI group. This commandallows 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:
In
client.py
, add acreate_issue
method to theUser
class tohandle the GraphQL mutation for creating issues. This method constructs
the mutation query and prints it for debugging purposes.
Example:
create_issue
method currently returns an empty list and does notexecute the GraphQL request. The line
# data = gql_request(query)
should be uncommented and properly implemented.
return Issue.from_dict(data["data"]["createIssue"]["issue"])
line is unreachable due to the preceding
return []
statement. Thefirst return statement should be removed.