[PR #453] [MERGED] Replace PrintTable/PrintMarkdown type switches with output registry #537

Closed
opened 2026-02-26 22:31:25 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rudrankriyam/App-Store-Connect-CLI/pull/453
Author: @rudrankriyam
Created: 2/8/2026
Status: Merged
Merged: 2/8/2026
Merged by: @rudrankriyam

Base: mainHead: refactor/output-registry


📝 Commits (1)

  • b95b90d refactor: replace PrintTable/PrintMarkdown type switches with registry

📊 Changes

63 files changed (+1014 additions, -6043 deletions)

View changed files

📝 internal/asc/actors_output.go (+0 -12)
📝 internal/asc/analytics_output.go (+0 -108)
📝 internal/asc/assets_output.go (+1 -136)
📝 internal/asc/build_bundles_output.go (+11 -74)
📝 internal/asc/categories_output.go (+0 -12)
📝 internal/asc/devices_output.go (+0 -24)
📝 internal/asc/eula_output.go (+0 -24)
📝 internal/asc/finance_output.go (+0 -24)
📝 internal/asc/iap_output.go (+0 -192)
📝 internal/asc/nominations_output.go (+0 -24)
📝 internal/asc/offer_codes_custom_output.go (+0 -42)
📝 internal/asc/offer_codes_output.go (+0 -24)
📝 internal/asc/output_accessibility.go (+0 -36)
📝 internal/asc/output_age_rating.go (+0 -12)
📝 internal/asc/output_alternative_distribution.go (+0 -100)
📝 internal/asc/output_android_ios_mapping.go (+0 -24)
📝 internal/asc/output_app_clips.go (+0 -204)
📝 internal/asc/output_app_events.go (+0 -84)
📝 internal/asc/output_app_info.go (+0 -12)
📝 internal/asc/output_app_setup.go (+0 -12)

...and 43 more files

📄 Description

Summary

Replace the two 942-case type switches in PrintTable/PrintMarkdown (1900 lines of mechanical dispatch) with a reflect.Type registry. Each response type registers its xxxRows function at init time; dispatch is a single map lookup.

  • output_core.go: 1947 lines -> 57 lines
  • All printXxxTable/printXxxMarkdown wrapper functions removed (dead code)
  • Multi-table types use registerDirect for composite rendering
  • Net -5029 lines across 63 files

Architecture

// Registration (output_registry_init.go)
registerRows(appsRows)                    // direct: *AppsResponse -> appsRows
registerRows(func(v *AppResponse) ...)    // wrapper: singular -> list
registerDirect(func(v *BuildUploadResult, render ...) error { ... }) // multi-table

// Dispatch (output_core.go)
func PrintTable(data any) error  { return renderByRegistry(data, RenderTable) }
func PrintMarkdown(data any) error { return renderByRegistry(data, RenderMarkdown) }

Adding a new output type now requires:

  1. Write one xxxRows function
  2. Add one registerRows(xxxRows) call

No more editing two switches in lockstep.

Test plan

  • make format passes
  • make lint passes (zero unused function warnings)
  • make test passes (all 7600+ tests)
  • Manual: asc apps list --output table renders bordered tables
  • Manual: asc apps list --output markdown renders markdown
  • Registry tests: non-empty, no nil handlers, expected type count, JSON fallback

Closes #444


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rudrankriyam/App-Store-Connect-CLI/pull/453 **Author:** [@rudrankriyam](https://github.com/rudrankriyam) **Created:** 2/8/2026 **Status:** ✅ Merged **Merged:** 2/8/2026 **Merged by:** [@rudrankriyam](https://github.com/rudrankriyam) **Base:** `main` ← **Head:** `refactor/output-registry` --- ### 📝 Commits (1) - [`b95b90d`](https://github.com/rudrankriyam/App-Store-Connect-CLI/commit/b95b90d36293557ce7c1998151a75e2e377e308b) refactor: replace PrintTable/PrintMarkdown type switches with registry ### 📊 Changes **63 files changed** (+1014 additions, -6043 deletions) <details> <summary>View changed files</summary> 📝 `internal/asc/actors_output.go` (+0 -12) 📝 `internal/asc/analytics_output.go` (+0 -108) 📝 `internal/asc/assets_output.go` (+1 -136) 📝 `internal/asc/build_bundles_output.go` (+11 -74) 📝 `internal/asc/categories_output.go` (+0 -12) 📝 `internal/asc/devices_output.go` (+0 -24) 📝 `internal/asc/eula_output.go` (+0 -24) 📝 `internal/asc/finance_output.go` (+0 -24) 📝 `internal/asc/iap_output.go` (+0 -192) 📝 `internal/asc/nominations_output.go` (+0 -24) 📝 `internal/asc/offer_codes_custom_output.go` (+0 -42) 📝 `internal/asc/offer_codes_output.go` (+0 -24) 📝 `internal/asc/output_accessibility.go` (+0 -36) 📝 `internal/asc/output_age_rating.go` (+0 -12) 📝 `internal/asc/output_alternative_distribution.go` (+0 -100) 📝 `internal/asc/output_android_ios_mapping.go` (+0 -24) 📝 `internal/asc/output_app_clips.go` (+0 -204) 📝 `internal/asc/output_app_events.go` (+0 -84) 📝 `internal/asc/output_app_info.go` (+0 -12) 📝 `internal/asc/output_app_setup.go` (+0 -12) _...and 43 more files_ </details> ### 📄 Description ## Summary Replace the two 942-case type switches in `PrintTable`/`PrintMarkdown` (1900 lines of mechanical dispatch) with a `reflect.Type` registry. Each response type registers its `xxxRows` function at init time; dispatch is a single map lookup. - `output_core.go`: 1947 lines -> 57 lines - All `printXxxTable`/`printXxxMarkdown` wrapper functions removed (dead code) - Multi-table types use `registerDirect` for composite rendering - **Net -5029 lines** across 63 files ## Architecture ``` // Registration (output_registry_init.go) registerRows(appsRows) // direct: *AppsResponse -> appsRows registerRows(func(v *AppResponse) ...) // wrapper: singular -> list registerDirect(func(v *BuildUploadResult, render ...) error { ... }) // multi-table // Dispatch (output_core.go) func PrintTable(data any) error { return renderByRegistry(data, RenderTable) } func PrintMarkdown(data any) error { return renderByRegistry(data, RenderMarkdown) } ``` Adding a new output type now requires: 1. Write one `xxxRows` function 2. Add one `registerRows(xxxRows)` call No more editing two switches in lockstep. ## Test plan - [x] `make format` passes - [x] `make lint` passes (zero unused function warnings) - [x] `make test` passes (all 7600+ tests) - [x] Manual: `asc apps list --output table` renders bordered tables - [x] Manual: `asc apps list --output markdown` renders markdown - [x] Registry tests: non-empty, no nil handlers, expected type count, JSON fallback Closes #444 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 22:31:25 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/App-Store-Connect-CLI#537
No description provided.