Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/commands/issue/issue-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import {
padDisplay,
truncateText,
} from "../../utils/display.ts"
import { fetchIssuesForState, getTeamKey } from "../../utils/linear.ts"
import {
fetchIssuesForState,
getProjectIdByName,
getProjectOptionsByName,
getTeamKey,
selectOption,
} from "../../utils/linear.ts"
import { openTeamAssigneeView } from "../../utils/actions.ts"
import { pipeToUserPager, shouldUsePager } from "../../utils/pager.ts"
import { header, muted } from "../../utils/styling.ts"
Expand Down Expand Up @@ -63,6 +69,10 @@ export const listCommand = new Command()
"--team <team:string>",
"Team to list issues for (if not your default team)",
)
.option(
"--project <project:string>",
"Filter by project name",
)
.option(
"--limit <limit:number>",
"Maximum number of issues to fetch (default: 50, use 0 for unlimited)",
Expand All @@ -85,6 +95,7 @@ export const listCommand = new Command()
app,
allStates,
team,
project,
limit,
pager,
},
Expand Down Expand Up @@ -135,6 +146,19 @@ export const listCommand = new Command()
Deno.exit(1)
}

let projectId: string | undefined
if (project != null) {
projectId = await getProjectIdByName(project)
if (projectId == null) {
const projectOptions = await getProjectOptionsByName(project)
if (Object.keys(projectOptions).length === 0) {
console.error(`No projects found matching: ${project}`)
Deno.exit(1)
}
projectId = await selectOption("Project", project, projectOptions)
}
}

const { Spinner } = await import("@std/cli/unstable-spinner")
const showSpinner = Deno.stdout.isTerminal()
const spinner = showSpinner ? new Spinner() : null
Expand All @@ -148,6 +172,7 @@ export const listCommand = new Command()
unassigned,
allAssignees,
limit === 0 ? undefined : limit,
projectId,
)
spinner?.stop()
const issues = result.issues?.nodes || []
Expand Down
5 changes: 5 additions & 0 deletions src/utils/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export async function fetchIssuesForState(
unassigned = false,
allAssignees = false,
limit?: number,
projectId?: string,
) {
const sort = getOption("issue_sort") as "manual" | "priority" | undefined
if (!sort) {
Expand Down Expand Up @@ -391,6 +392,10 @@ export async function fetchIssuesForState(
filter.assignee = { isMe: { eq: true } }
}

if (projectId) {
filter.project = { id: { eq: projectId } }
}

const query = gql(/* GraphQL */ `
query GetIssuesForState($sort: [IssueSortInput!], $filter: IssueFilter!, $first: Int, $after: String) {
issues(filter: $filter, sort: $sort, first: $first, after: $after) {
Expand Down
1 change: 1 addition & 0 deletions test/commands/issue/__snapshots__/issue-list.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Options:
-U, --unassigned - Show only unassigned issues
--sort <sort> - Sort order (can also be set via LINEAR_ISSUE_SORT) (Values: \\x1b[32m"manual"\\x1b[39m, \\x1b[32m"priority"\\x1b[39m)
--team <team> - Team to list issues for (if not your default team)
--project <project> - Filter by project name
--limit <limit> - Maximum number of issues to fetch (default: 50, use 0 for unlimited) (Default: \\x1b[33m50\\x1b[39m)
-w, --web - Open in web browser
-a, --app - Open in Linear.app
Expand Down
Loading