Skip to content

Commit ec30c32

Browse files
committed
Update init for C and Java
1 parent 18ac016 commit ec30c32

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

src/cli/handlers/init/index.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,55 @@ function suggestIncludePatterns(
531531
if (suggestions.length === 0) {
532532
suggestions.push("**/*.cs");
533533
}
534+
} else if (language === cLanguage) {
535+
// Check for common C project structures
536+
if (projectStructure.some((entry) => entry.includes("📂 src/"))) {
537+
suggestions.push("src/**/*.c");
538+
suggestions.push("src/**/*.h");
539+
}
540+
if (projectStructure.some((entry) => entry.includes("📂 lib/"))) {
541+
suggestions.push("lib/**/*.c");
542+
suggestions.push("lib/**/*.h");
543+
}
544+
if (suggestions.length === 0) {
545+
if (projectStructure.some((entry) => entry.includes("📂 include/"))) {
546+
suggestions.push("include/**/*.c");
547+
suggestions.push("include/**/*.h");
548+
}
549+
}
550+
if (suggestions.length === 0) {
551+
suggestions.push("**/*.c");
552+
suggestions.push("**/*.h");
553+
}
554+
} else if (language === javaLanguage) {
555+
// Check for common Java project structures
556+
if (projectStructure.some((entry) => entry.includes("📂 src/"))) {
557+
suggestions.push("src/**/*.java");
558+
}
559+
if (projectStructure.some((entry) => entry.includes("📂 lib/"))) {
560+
suggestions.push("lib/**/*.java");
561+
}
562+
if (suggestions.length === 0) {
563+
if (projectStructure.some((entry) => entry.includes("📂 buildSrc/"))) {
564+
suggestions.push("buildSrc/**/*.java");
565+
}
566+
if (projectStructure.some((entry) => entry.includes("📂 app/"))) {
567+
suggestions.push("app/**/*.java");
568+
}
569+
if (projectStructure.some((entry) => entry.includes("📂 core/"))) {
570+
suggestions.push("core/**/*.java");
571+
}
572+
if (projectStructure.some((entry) => entry.includes("📂 util/"))) {
573+
suggestions.push("util/**/*.java");
574+
}
575+
if (projectStructure.some((entry) => entry.includes("📂 libs/"))) {
576+
suggestions.push("libs/**/*.java");
577+
}
578+
}
579+
if (suggestions.length === 0) {
580+
suggestions.push("**/*.c");
581+
suggestions.push("**/*.h");
582+
}
534583
}
535584

536585
return suggestions;
@@ -577,6 +626,22 @@ function suggestExcludePatterns(
577626
suggestions.push("**/.nuget/**");
578627
suggestions.push("**/artifacts/**");
579628
suggestions.push("**/packages/**");
629+
} else if (language === cLanguage) {
630+
suggestions.push("**/bin/**");
631+
suggestions.push("**/obj/**");
632+
suggestions.push("**/.bin/**");
633+
suggestions.push("**/.obj/**");
634+
suggestions.push("**/target/**");
635+
suggestions.push("**/.vscode/**");
636+
} else if (language === javaLanguage) {
637+
suggestions.push("**/bin/**");
638+
suggestions.push("**/obj/**");
639+
suggestions.push("**/.bin/**");
640+
suggestions.push("**/.obj/**");
641+
suggestions.push("**/target/**");
642+
suggestions.push("**/.vscode/**");
643+
suggestions.push("**/.mvn/**");
644+
suggestions.push("**/.svn/**");
580645
}
581646

582647
return suggestions;
@@ -840,6 +905,25 @@ export async function generateConfig(
840905
}
841906
}
842907

908+
// C-specific config
909+
let cConfig: z.infer<typeof localConfigSchema>["c"] | undefined = undefined;
910+
if (language === cLanguage) {
911+
const includeDirs = await search<string[]>({
912+
message:
913+
`Enter the include directories containing header files, separated by commas (usually specified in Makefile, if none leave blank)`,
914+
source: (term) => {
915+
if (!term) return [];
916+
return term.split(/, ?/);
917+
},
918+
});
919+
920+
if (includeDirs) {
921+
cConfig = {
922+
includedirs: includeDirs,
923+
};
924+
}
925+
}
926+
843927
// Output directory - must be a valid directory name within the project
844928
const outDir = await input({
845929
message: "Enter the output directory for NanoAPI artifacts",
@@ -908,5 +992,10 @@ export async function generateConfig(
908992
config.python = pythonConfig;
909993
}
910994

995+
// Add C config if it exists
996+
if (cConfig) {
997+
config.c = cConfig;
998+
}
999+
9111000
return config;
9121001
}

0 commit comments

Comments
 (0)