mmkal / mmkal/trpc-cli

low-level configurability

Open
#103 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
373
Forks
13
PR merge metrics
No merged PRs in 30d

Description

at this point there are a fair few decisions that trpc-cli makes for you when deciding how to create options, negations etc.

it'd be overkill to provide explicit levers to pull to change all of that, but maybe the commander module could be injectable so that people can just do their own little hacks like

import * as commander from 'commander'

class Command extends commander.Command {
  addOption(option: Option) {
    if (this.name() === 'say-hello' && option.name() === 'foo') {
      option.description(`${option.description()} - btw this has very verbose output so mebe use jq or whatever`)
    }
    if (this.name() === 'say-goodbye' && option.name() === 'bar') {
      // router comes from another module we can't add `.meta` to for some reason
      option.flags = `${option.flags}, -b`
    }
    super.addOption(option)
  }
}

const cli = createCli({
  router: myRouter,
  commander: {....commander, Command}
})
cli.run()

This is theoretically possible now via buildProgram() but it's (even more) inconvenient.

Or opt-out of the booleans-get-negated-automatically functionality of #102:

import * as commander from 'commander'

class Command extends commander.Command {
  addOption(option: Option) {
    if (option.flags.includes('--no-') return
    super.addOption(option)
  }
}

const cli = createCli({
  router: myRouter,
  commander: {....commander, Command}
})
cli.run()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at buildProgram() and createCli(), then trace how commander constructs options, negations, and the program instance. Done means callers can inject a customized commander Command implementation without relying on the inconvenient buildProgram() path, while existing CLI behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.