Skip to content

Refactor how CLI commands are added to pepr in src/cli.ts #2474

@samayer12

Description

@samayer12

Describe what should be investigated or refactored

While working on #2395, I noticed a pattern in Pepr that seemed a little counter to how commander composes commands and subcommands.

We should add commands to the root pepr command by using .addCommand() instead of our current approach of passing the entire pepr command object into a function that adds on another subcommand. The outcome will be the same, but the way we modify the CLI structure should be more intuitive to someone unfamiliar with the project.

Links to any relevant code

src/cli.ts

Our current approach is something like:

import subcommand from "somewhere"
const program = new Command()
subcommand(program)

A preferred approach modeled in #2395 would be like:

import subcommand from "somewhere"
const program = new Command()
program.addCommand(subcommand)

Additional context

Commander docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions