Skip to content

Commit 045fde4

Browse files
committed
fix: add --projects flag for non-interactive project selection
1 parent 7538d5f commit 045fde4

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yavydev/cli",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Search and manage your AI-ready documentation on Yavy",
55
"type": "module",
66
"bin": {

src/commands/init.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function initCommand(): Command {
1212
return new Command('init')
1313
.description('Set up Yavy for your AI tools (skills + MCP config)')
1414
.option('--tool <name>', 'Configure a specific tool only')
15+
.option('--projects <slugs>', 'Comma-separated project slugs to configure (skips interactive selection)')
1516
.option('--yes', 'Non-interactive mode: configure all detected tools + all projects')
1617
.action(async (options: InitOptions) => {
1718
try {
@@ -133,6 +134,30 @@ async function selectTools(options: InitOptions): Promise<AiTool[]> {
133134
}
134135

135136
async function selectProjects(projects: ApiProject[], options: InitOptions): Promise<ApiProject[]> {
137+
if (options.projects) {
138+
const requestedSlugs = new Set(
139+
options.projects
140+
.split(',')
141+
.map((s) => s.trim())
142+
.filter(Boolean),
143+
);
144+
const matched = projects.filter((proj) => requestedSlugs.has(proj.slug));
145+
146+
if (matched.length === 0) {
147+
p.log.error('No matching projects found for the provided slugs.');
148+
p.log.info(`Available: ${projects.map((proj) => proj.slug).join(', ')}`);
149+
process.exit(1);
150+
}
151+
152+
const unmatched = [...requestedSlugs].filter((s) => !matched.some((proj) => proj.slug === s));
153+
if (unmatched.length > 0) {
154+
warn(`Skipping unknown slugs: ${unmatched.join(', ')}`);
155+
}
156+
157+
p.log.info(`Selected ${matched.length} project(s) via --projects`);
158+
return matched;
159+
}
160+
136161
if (options.yes) {
137162
p.log.info(`Auto-selecting all ${projects.length} project(s)`);
138163
return projects;

src/commands/init/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface ToolConfig {
1717

1818
export interface InitOptions {
1919
tool?: string;
20+
projects?: string;
2021
yes?: boolean;
2122
}
2223

0 commit comments

Comments
 (0)