Skip to content

Commit dfaeb3e

Browse files
committed
Add shell completion for bash, zsh, and fish
Introduces a `ggt completion` command that emits accurate completion scripts covering commands, subcommands, flags, and dynamic value providers (app names, environments, log levels, editors). A hidden `--__complete` root flag routes live completion requests through a handler/provider layer. Generators suppress filename fallback in all three shells. Refactors the args layer in preparation: long flag names become canonical with short forms as aliases, completion functions are inlined into flag definitions, and MergeConflictPreferenceValues is exported for direct reference. AppIdentityArgs is moved to app-identity.ts and SyncJsonArgs is inlined into sync-json.ts to break ESM init cycles that caused flag stripping in CI. Test coverage includes shell syntax validation against real binaries, behavioral regression tests, and snapshot tests for all three generators. Deterministic shell versions are pinned in the nix dev shell so CI runs against stable binaries.
1 parent 26f04ca commit dfaeb3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4303
-256
lines changed

.changeset/add-shell-completion.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"ggt": minor
3+
---
4+
5+
Add `ggt completion` command for generating shell completion scripts
6+
7+
Supports Bash, Zsh, and Fish shells. Run `ggt completion <shell>` to generate
8+
a completion script, then source it in your shell configuration.

.claude/rules/services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Defined in `src/services/output/`.
5555

5656
### Formatting
5757

58-
- `sprint` / `sprintln` — template literal tag combining `chalk-template` + `dedent`. Also accepts options form: `sprint({ content, indent, boxen, ensureNewLine, ensureEmptyLineAbove })`
58+
- `sprint` / `sprintln` — template literal tag combining `chalk-template` + `dedent`. Also accepts options form: `sprint({ content, indent, boxen, ensureNewLine, ensureEmptyLineAbove })`. Multiline interpolated values are automatically aligned to the insertion column (`alignMultilineValues`), so use plain `"\n"` in `.join()` — never pad with manual spaces.
5959
- `println` / `print` — write formatted text to stdout (no-op in JSON mode unless `json` option is set)
6060

6161
### Interactive elements

.cspell/project-words.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ appvalue
22
clickhouse
33
codegen
44
commandsstop
5+
compadd
6+
compdef
7+
compgen
8+
compinit
9+
compreply
10+
cword
511
dedenting
612
dggt
713
direnv
@@ -14,6 +20,7 @@ enotdir
1420
enotempty
1521
envrc
1622
eproto
23+
esac
1724
esbuild
1825
execa
1926
filesync

nix/flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
in
1414
{
1515
packages = {
16+
bash = pkgs.bash;
1617
corepack = pkgs.corepack;
1718
direnv = pkgs.direnv;
19+
fish = pkgs.fish;
1820
git = pkgs.git;
1921
mkcert = pkgs.mkcert;
2022
nix-direnv = pkgs.nix-direnv;
2123
nixpkgs-fmt = pkgs.nixpkgs-fmt;
2224
nodejs = pkgs.nodejs_20;
2325
yarn = pkgs.yarn.override { nodejs = flake.packages.nodejs; };
26+
zsh = pkgs.zsh;
2427

2528
ggt = pkgs.writeShellScriptBin "ggt" ''
2629
GGT_ENV=production "$WORKSPACE_ROOT"/dist/main.js "$@"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@types/tcp-port-used": "^1.0.0",
6565
"@types/which": "^3.0.4",
6666
"@types/ws": "^8.18.1",
67+
"@vitest/coverage-v8": "^4.0.18",
6768
"ansi-escapes": "^7.2.0",
6869
"arg": "^5.0.2",
6970
"boxen": "^8.0.1",

pnpm-lock.yaml

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/__support__/filesync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export type FileSyncScenarioOptions = {
5252
/**
5353
* The arguments to pass to the {@linkcode SyncJson} instance.
5454
*
55-
* @default { _: [testDirPath("local")], ["--app"]: testEnvironment.application.slug, ["--env"]: testEnvironment.name }
55+
* @default { _: [testDirPath("local")], ["--application"]: testEnvironment.application.slug, ["--environment"]: testEnvironment.name }
5656
*/
5757
args?: SyncJsonArgsResult;
5858

0 commit comments

Comments
 (0)