import { r as ux } from "./cli-B86kvKcR.mjs";
import { n as getInstalledPluginsForScope } from "./plugins-DtsrBxYU.mjs";
import process from "node:process";
import { defineCommand } from "citty";
//#region src/commands/plugin/list.ts
async function runPluginListCommand(options = {}) {
	try {
		const plugins = await ux.running("Loading installed plugins", async () => getInstalledPluginsForScope({ global: options.global }));
		if (options.json) {
			process.stdout.write(`${JSON.stringify(plugins, null, 2)}\n`);
			return plugins;
		}
		if (plugins.length === 0) {
			ux.log.info("No installed plugins found.");
			return plugins;
		}
		for (const plugin of plugins) {
			console.log(plugin.name);
			console.log(`  scope: ${plugin.scope}`);
			console.log(`  path: ${plugin.canonicalPath}`);
		}
		return plugins;
	} catch (error) {
		ux.handleError(error);
		return;
	}
}
var list_default = defineCommand({
	meta: {
		name: "list",
		description: "List installed OpenCode plugins"
	},
	args: {
		global: {
			alias: "g",
			type: "boolean",
			description: "List globally installed plugins"
		},
		json: {
			type: "boolean",
			description: "Output machine-readable JSON"
		}
	},
	async run({ args }) {
		await runPluginListCommand({
			global: args.global,
			json: args.json
		});
		if (!process.exitCode) process.exit(0);
	}
});
//#endregion
export { runPluginListCommand as n, list_default as t };

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