import { r as ux } from "./cli-B86kvKcR.mjs";
import { n as formatIssueSummary, r as listIssues } from "./issues-Db9BW4-6.mjs";
import process from "node:process";
import { defineCommand } from "citty";
//#region src/commands/issue/list.ts
async function runIssueListCommand(options = {}) {
	try {
		const issues = await ux.running("Loading issues", async () => await listIssues(options));
		if (options.json) {
			process.stdout.write(`${JSON.stringify(issues, null, 2)}\n`);
			return;
		}
		if (issues.length === 0) {
			ux.log.info("No issues found.");
			return;
		}
		for (const issue of issues) {
			console.log(formatIssueSummary(issue));
			console.log(`  page: ${issue.id}`);
			if (issue.url) console.log(`  url: ${issue.url}`);
		}
	} catch (error) {
		ux.handleError(error);
	}
}
var list_default = defineCommand({
	meta: {
		name: "list",
		description: "List HQ Rhythm issues"
	},
	args: {
		condition: {
			type: "string",
			description: "Filter by condition"
		},
		json: {
			type: "boolean",
			description: "Output machine-readable JSON"
		},
		kind: {
			type: "string",
			description: "Filter by kind"
		},
		level: {
			type: "string",
			description: "Filter by level"
		},
		limit: {
			type: "string",
			description: "Limit the number of results"
		},
		owner: {
			type: "string",
			description: "Filter by owner text"
		},
		progress: {
			type: "string",
			description: "Filter by progress status"
		},
		query: {
			alias: "q",
			type: "string",
			description: "Filter by lightweight text query"
		},
		reporter: {
			type: "string",
			description: "Filter by reporter"
		},
		stage: {
			type: "string",
			description: "Filter by stage or Level/Stage value"
		},
		workspace: {
			type: "string",
			description: "Filter by workspace"
		}
	},
	async run({ args }) {
		await runIssueListCommand({
			condition: args.condition,
			json: args.json,
			kind: args.kind,
			level: args.level,
			limit: args.limit ? Number.parseInt(args.limit, 10) : void 0,
			owner: args.owner,
			progress: args.progress,
			query: args.query,
			reporter: args.reporter,
			stage: args.stage,
			workspace: args.workspace
		});
		if (!process.exitCode) process.exit(0);
	}
});
//#endregion
export { list_default as default };

//# sourceMappingURL=list-hYQLOyo1.mjs.map