Skip to content

Commit 81cbf01

Browse files
Vonngclaude
andcommitted
refactor(cc): simplify CC generators by extracting shared helpers
Extract common patterns duplicated across CC generators into shared functions: - ReadyExtensions() on ExtensionCache replaces inline filtering and readyExts() - GetVersion() / GetPkgURLLink() on Extension replace repeated null-check patterns - InferRepo() consolidates duplicate inferRepo methods from cc_page.go and cc_os.go - WriteMarkdownFile() replaces repeated os.MkdirAll + os.WriteFile boilerplate - runWithCache() in cmd/cc.go extracts InitDB+LoadCache boilerplate from 6 commands - CCExtensionTable uses shared helpers, removing duplication in cc_markdown.go - Remove NullBool/NullString type aliases in favor of direct sql.Null* types Net reduction: ~350 lines removed across 9 files with no functional changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a57e67b commit 81cbf01

File tree

9 files changed

+770
-735
lines changed

9 files changed

+770
-735
lines changed

cli/cache.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ func buildDependencyMap(cache *ExtensionCache) {
246246
}
247247
}
248248

249+
// ReadyExtensions returns all extensions that are not in "not-ready" state
250+
func (cache *ExtensionCache) ReadyExtensions() []*Extension {
251+
var exts []*Extension
252+
for _, ext := range cache.Extensions {
253+
if ext.IsReady() {
254+
exts = append(exts, ext)
255+
}
256+
}
257+
return exts
258+
}
259+
249260
// GetSiblingExtensions returns other extensions that share the same package
250261
func (cache *ExtensionCache) GetSiblingExtensions(pkgName, currentExtName string) []*Extension {
251262
var siblings []*Extension

0 commit comments

Comments
 (0)