Skip to content

refactor: standardize command registration pattern #18

@rianjs

Description

@rianjs

Summary

Standardize on the Register(parent, opts) command registration pattern across both tools.

Current State

cfl pattern (tools/cfl/internal/cmd/root/root.go):

// Commands added directly in NewCmdRoot()
cmd.AddCommand(page.NewCmdPage())
cmd.AddCommand(space.NewCmdSpace())

jtk pattern (tools/jtk/cmd/jtk/main.go):

// Uses Register() pattern with opts injection
issues.Register(rootCmd, opts)
boards.Register(rootCmd, opts)

Proposed Changes

  1. Update cfl commands to use Register(parent *cobra.Command, opts *root.Options) pattern
  2. Rename NewCmdX() to Register() for consistency
  3. Pass shared Options through the command tree

Benefits

  • Better dependency injection for API clients, view renderers
  • Improved testability
  • Consistent pattern across both tools
  • Eliminates need to parse global flags in each command

Depends On

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions