Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
61 changes: 42 additions & 19 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ func runGenerate(cmd *cobra.Command, args []string) error { //nolint:gocyclo //
noStream, _ := cmd.Flags().GetBool("no-stream")
//nolint:errcheck
concurrency, _ := cmd.Flags().GetInt("concurrency")
//nolint:errcheck
excludeRoutes, _ := cmd.Flags().GetStringSlice("exclude-route")
//nolint:errcheck
excludeRoutePrefixes, _ := cmd.Flags().GetStringSlice("exclude-route-prefix")

if len(excludeRoutes) == 0 {
excludeRoutes = config.Get().Extract.ExcludeRoutes
}
if len(excludeRoutePrefixes) == 0 {
excludeRoutePrefixes = config.Get().Extract.ExcludeRoutePrefixes
}

// Step 1: Detect framework - try all registered extractors
extractorImpl, info, err := builtin.DetectFramework(path)
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -153,11 +164,13 @@ func runGenerate(cmd *cobra.Command, args []string) error { //nolint:gocyclo //
}

genOpts := &extractor.GenerateOptions{
OutputDir: outputDir,
Format: outputFormat,
Timeout: timeout,
SkipTests: true,
ProtoImportPaths: protoImportPaths,
OutputDir: outputDir,
Format: outputFormat,
Timeout: timeout,
SkipTests: true,
ProtoImportPaths: protoImportPaths,
ExcludeRoutes: excludeRoutes,
ExcludeRoutePrefixes: excludeRoutePrefixes,
}

genResult, err := extractorImpl.Generate(ctx, path, info, genOpts)
Expand Down Expand Up @@ -321,6 +334,10 @@ to preserve your project's formatting. Use --keep-patched to keep the changes.`,
"disable streaming to enable concurrent LLM calls (faster, but no real-time output)")
c.Flags().Int("concurrency", 3,
"max concurrent LLM calls (only effective with --no-stream)")
c.Flags().StringSlice("exclude-route", nil,
"exact route paths to exclude from the generated spec (can be specified multiple times)")
c.Flags().StringSlice("exclude-route-prefix", nil,
"route path prefixes to exclude from the generated spec (can be specified multiple times)")

registerCompletion(c, "output", []string{"yaml", "json"})
registerCompletion(c, "language", []string{"en", "zh"})
Expand All @@ -331,20 +348,22 @@ to preserve your project's formatting. Use --keep-patched to keep the changes.`,

// generate command flag variables for global rootCmd only
var (
generateKeepPatched bool
generateSkipValidate bool
generateTimeout time.Duration
generateSkipEnrich bool
generateLanguage string
generateOutputDir string
generateOutputFormat string
generateSkipPublish bool
generatePublishTarget string
generatePublishOverwrite bool
generateOverwriteOutput bool
generateProtoImportPaths []string
generateNoStream bool
generateConcurrency int
generateKeepPatched bool
generateSkipValidate bool
generateTimeout time.Duration
generateSkipEnrich bool
generateLanguage string
generateOutputDir string
generateOutputFormat string
generateSkipPublish bool
generatePublishTarget string
generatePublishOverwrite bool
generateOverwriteOutput bool
generateProtoImportPaths []string
generateNoStream bool
generateConcurrency int
generateExcludeRoutes []string
generateExcludeRoutePrefixes []string
)

func init() {
Expand Down Expand Up @@ -378,6 +397,10 @@ func init() {
"disable streaming to enable concurrent LLM calls (faster, but no real-time output)")
generateCmd.Flags().IntVar(&generateConcurrency, "concurrency", 3,
"max concurrent LLM calls (only effective with --no-stream)")
generateCmd.Flags().StringSliceVar(&generateExcludeRoutes, "exclude-route", nil,
"exact route paths to exclude from the generated spec (can be specified multiple times)")
generateCmd.Flags().StringSliceVar(&generateExcludeRoutePrefixes, "exclude-route-prefix", nil,
"route path prefixes to exclude from the generated spec (can be specified multiple times)")

registerCompletion(generateCmd, "output", []string{"yaml", "json"})
registerCompletion(generateCmd, "language", []string{"en", "zh"})
Expand Down
Loading
Loading