mmkal / mmkal/trpc-cli

Suppress `Alias` in help text option description?

Open
#154 1 comment 1 reaction 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

The program below prints help text that gives the user alias help text in two locations:

import { initTRPC } from "@trpc/server";
import { createCli } from "trpc-cli";
import { z } from "zod";

const t = initTRPC.create();

const router = t.router({
  add: t.procedure
    .meta({})
    .input(
      z.object({
        left: z.number().meta({ alias: "l", description: "Left number" }),
        right: z.number().meta({ alias: "r", description: "Right number" }),
      })
    )
    .query(({ input }) => input.left + input.right),
});

createCli({ router }).run();

The help text:

Usage: index add [options]

Options:
  -l, --left <number>   Left number; Alias: l
  -r, --right <number>  Right number; Alias: r
  -h, --help            display help for command

Is there a way to hide/not print the Alias: l and Alias: r. They're redundant, given that -l, --left/-r, --right is printed at the start of the line.

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 the createCli({ router }).run() entry point and trace how the schema metadata is rendered in command help. Compare the generated option description with the reported output and determine whether the redundant alias text can be suppressed. Done means help shows -l, --left and -r, --right with their descriptions but without the appended Alias text.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.