CLI: shell completions (kgdiff completion bash|zsh|fish)

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
57/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli

Research direction

Start with the option tables and constants in packages/cli/src/args.ts, then read parseCommandLine to see how apply and help are dispatched; check locale values in locale.ts. The issue calls for generated bash, zsh, and fish scripts, tests and snapshots, help and English and Chinese docs, and a changeset. Done means those checks and docs are in place and at least one shell has been tried by hand.

Written by the indexing model from the issue text.

Description

cli enhancement good first issue
What

kgdiff completion <shell> prints a completion script for bash, zsh or fish, to be installed
the usual way:

kgdiff completion zsh > "${fpath[1]}/_kgdiff"
kgdiff completion bash > ~/.local/share/bash-completion/completions/kgdiff
kgdiff completion fish > ~/.config/fish/completions/kgdiff.fish

The script should complete:

  • options, with their short forms (-o, -f, -q…);
  • the values of options that take a fixed set: --format, --before-format,
    --after-format, --match, --edge-identity, --theme, --mode, --scope, --color,
    --locale;
  • file names for the two graph arguments and for options that take a file (-o, --json…);
  • the apply and help subcommands and their own options.
Where to start
  • The options and their types are tables in packages/cli/src/args.ts (COMMON at
    #L112
    and the ones after it), and the allowed values are the constants at the top of the file
    (FORMATS, MATCH_STRATEGIES, EDGE_IDENTITIES, THEMES, MODES, SCOPES,
    COLOR_MODES; locales come from LOCALES in locale.ts). Generate the
    scripts from these tables
    rather than writing the lists by hand, so completions never fall
    behind the options.
  • Subcommands are dispatched in parseCommandLine
    (#L584):
    completion goes next to apply and help, with a new kind in the Command union.
  • Help text: packages/cli/src/help.ts. Docs: docs/cli.md and docs/zh/cli.md.
Done when
  • A test checks that every option in the tables appears in each script, and snapshot tests pin
    the three scripts.
  • You tried at least one shell by hand (say which in the pull request).
  • kgdiff help and docs/cli.md (en + zh) mention it, and there is a changeset.
Dominant language
TypeScript
Stars
47
Forks
6
Avg merge
2h 32m
Merged PRs (30d)
22

Getting set up

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.

More from iiwish/kgdiff

All issues in iiwish/kgdiff

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.