postman-cli-completion 1.39.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +145 -0
- package/bin/postman-completion.mjs +83 -0
- package/completions/bash/postman.bash +1078 -0
- package/completions/fish/postman.fish +574 -0
- package/completions/zsh/_postman +1294 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yoichi Kawasaki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# postman-cli-completion
|
|
2
|
+
|
|
3
|
+
Shell completion scripts for the [Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/) (`postman`) on **zsh**, **bash**, and **fish**.
|
|
4
|
+
|
|
5
|
+
Completes:
|
|
6
|
+
|
|
7
|
+
- All top-level commands (`login`, `collection`, `spec`, `monitor`, `workspace`, `flows`, etc.) and their subcommands.
|
|
8
|
+
- Flags for each (sub)command.
|
|
9
|
+
- Local file arguments such as `*.json` (collections, manifests) and `*.yaml`/`*.yml` (specs, simulate scenarios).
|
|
10
|
+
|
|
11
|
+
Dynamic completion of remote IDs (collection / workspace / monitor IDs) is **not** supported — paste those yourself.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
### Via npm (recommended)
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g postman-cli-completion
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This installs a `postman-completion` helper command — it does **not** shadow the real
|
|
22
|
+
`postman` CLI (install that separately via `npm i -g postman-cli`). The helper prints the
|
|
23
|
+
completion script for your shell to stdout; wire it in as follows.
|
|
24
|
+
|
|
25
|
+
**zsh** — quick test in the current shell (requires `compinit` already initialised, see
|
|
26
|
+
the note below):
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
source <(postman-completion zsh)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**zsh** — persistent. Add the packaged completions dir to `fpath` in `~/.zshrc`:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
fpath=("$(postman-completion path zsh --dir)" $fpath)
|
|
36
|
+
autoload -Uz compinit && compinit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**bash** — add to `~/.bashrc` (requires bash 4+; see the bash note below):
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
source <(postman-completion bash)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**fish** — source it in the current session, or install it persistently:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
postman-completion fish | source
|
|
49
|
+
# persistent:
|
|
50
|
+
ln -sf "$(postman-completion path fish)" ~/.config/fish/completions/postman.fish
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### From source
|
|
54
|
+
|
|
55
|
+
Clone this repo somewhere, e.g. `~/.postman-cli-completion`:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
git clone https://github.com/yokawasa/postman-cli-completion.git ~/.postman-cli-completion
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### zsh
|
|
62
|
+
|
|
63
|
+
Add the completions directory to `fpath` and rerun `compinit`. Put this in `~/.zshrc`:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
fpath=(~/.postman-cli-completion/completions/zsh $fpath)
|
|
67
|
+
autoload -Uz compinit && compinit
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or, for a quick test in the current shell:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
source ~/.postman-cli-completion/completions/zsh/_postman
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> **Note:** `compinit` must already be initialised in your shell for `source` to register the completion. Most zsh setups (oh-my-zsh, prezto, or a plain `.zshrc` that runs `autoload -Uz compinit && compinit`) do this automatically. If `postman <TAB>` still does nothing after sourcing, run `autoload -Uz compinit && compinit` first and try again.
|
|
77
|
+
|
|
78
|
+
### bash
|
|
79
|
+
|
|
80
|
+
Add to `~/.bashrc` (or `~/.bash_profile` on macOS):
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
source ~/.postman-cli-completion/completions/bash/postman.bash
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Requires bash 4+ (`shopt -s extglob`). On macOS the system bash is 3.2 — install a newer bash via Homebrew (`brew install bash`) if needed.
|
|
87
|
+
|
|
88
|
+
### fish
|
|
89
|
+
|
|
90
|
+
Copy or symlink into fish's completion directory:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
ln -s ~/.postman-cli-completion/completions/fish/postman.fish \
|
|
94
|
+
~/.config/fish/completions/postman.fish
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or source it in the current session:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
source ~/.postman-cli-completion/completions/fish/postman.fish
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Verify (manual checklist)
|
|
104
|
+
|
|
105
|
+
After installing for your shell, open a fresh terminal and check each:
|
|
106
|
+
|
|
107
|
+
| Input | Expected |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `postman <TAB>` | All top-level commands appear |
|
|
110
|
+
| `postman col<TAB>` | Completes to `collection` |
|
|
111
|
+
| `postman collection <TAB>` | `migrate`, `lint`, `run` |
|
|
112
|
+
| `postman collection run <TAB>` | `*.json` files in the current directory |
|
|
113
|
+
| `postman collection run --<TAB>` | Flag list (`--environment`, `--iteration-data`, `--reporters`, …) |
|
|
114
|
+
| `postman collection run -r <TAB>` | `cli`, `json`, `junit`, `html` |
|
|
115
|
+
| `postman request <TAB>` | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` |
|
|
116
|
+
| `postman spec lint <TAB>` | `*.yaml` / `*.yml` / `*.json` files |
|
|
117
|
+
| `postman flows <TAB>` | `list`, `trigger`, `deploy`, `run`, `update`, `list-runs`, `get-run` |
|
|
118
|
+
| `postman --<TAB>` | `--silent`, `--color`, `--version`, `--help` |
|
|
119
|
+
|
|
120
|
+
## Versioning
|
|
121
|
+
|
|
122
|
+
The completion scripts are auto-generated from a single source of truth (`spec/commands.json`) and tracked against the upstream Postman CLI by two GitHub Actions workflows:
|
|
123
|
+
|
|
124
|
+
- **`catchup.yml`** runs daily, queries npm for the latest `postman-cli` version, introspects its `--help` surface, regenerates the spec and the three completion scripts, and opens an auto-merging PR whenever something changed.
|
|
125
|
+
- **`release.yml`** fires when `spec/commands.json` lands on `main` and publishes a matching GitHub Release (e.g. tag `v1.39.0` mirrors Postman CLI 1.39.0).
|
|
126
|
+
|
|
127
|
+
So this repo follows the latest published Postman CLI version automatically — pull the latest `main` (or grab the matching tag) and the completions will match whatever Postman CLI version you have installed.
|
|
128
|
+
|
|
129
|
+
Suspicious catchup diffs (≥30 % flag drop, a known fixed command missing, semver regression) are blocked by `scripts/validate-diff.mjs` and stay open for human review instead of auto-merging.
|
|
130
|
+
|
|
131
|
+
To check the version the committed spec was generated against:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
node -p "require('./spec/commands.json').postmanCliVersion"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
And your installed Postman CLI:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
postman --version
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
[MIT](./LICENSE) — see the LICENSE file.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
// bin/ lives one level under the package root. Resolve completion files relative
|
|
7
|
+
// to this module (NOT process.cwd(), which is the user's shell directory).
|
|
8
|
+
const PKG_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
|
|
10
|
+
const FILES = {
|
|
11
|
+
zsh: resolve(PKG_ROOT, "completions/zsh/_postman"),
|
|
12
|
+
bash: resolve(PKG_ROOT, "completions/bash/postman.bash"),
|
|
13
|
+
fish: resolve(PKG_ROOT, "completions/fish/postman.fish"),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const USAGE = `postman-completion — shell completions for the Postman CLI
|
|
17
|
+
|
|
18
|
+
Note: this installs the command "postman-completion"; it does NOT shadow the
|
|
19
|
+
real "postman" CLI (install that separately via "npm i -g postman-cli").
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
postman-completion <zsh|bash|fish> Print the completion script to stdout
|
|
23
|
+
postman-completion path <zsh|bash|fish> Print the packaged file's absolute path
|
|
24
|
+
postman-completion path <shell> --dir Print the file's directory (for zsh fpath)
|
|
25
|
+
postman-completion --help Show this help
|
|
26
|
+
|
|
27
|
+
Wire it into your shell:
|
|
28
|
+
|
|
29
|
+
# bash — add to ~/.bashrc (requires bash 4+)
|
|
30
|
+
source <(postman-completion bash)
|
|
31
|
+
|
|
32
|
+
# zsh — quick test in the current shell (compinit must be initialised)
|
|
33
|
+
source <(postman-completion zsh)
|
|
34
|
+
|
|
35
|
+
# zsh — persistent, add to ~/.zshrc
|
|
36
|
+
fpath=("$(postman-completion path zsh --dir)" $fpath)
|
|
37
|
+
autoload -Uz compinit && compinit
|
|
38
|
+
|
|
39
|
+
# fish — in the current session
|
|
40
|
+
postman-completion fish | source
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
function die(message) {
|
|
44
|
+
process.stderr.write(`postman-completion: ${message}\n`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function emit(shell) {
|
|
49
|
+
const file = FILES[shell];
|
|
50
|
+
if (!file) die(`unknown shell: ${shell} (expected zsh, bash, or fish)`);
|
|
51
|
+
process.stdout.write(readFileSync(file, "utf8"));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function printPath(args) {
|
|
55
|
+
const dirOnly = args.includes("--dir");
|
|
56
|
+
const shell = args.find((a) => a !== "--dir");
|
|
57
|
+
const file = FILES[shell];
|
|
58
|
+
if (!file) die(`unknown shell: ${shell ?? "(none)"} (expected zsh, bash, or fish)`);
|
|
59
|
+
process.stdout.write(`${dirOnly ? dirname(file) : file}\n`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function main(argv) {
|
|
63
|
+
const [cmd, ...rest] = argv;
|
|
64
|
+
|
|
65
|
+
if (!cmd || cmd === "--help" || cmd === "-h" || cmd === "help") {
|
|
66
|
+
process.stdout.write(USAGE);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (cmd === "path") {
|
|
71
|
+
printPath(rest);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (cmd in FILES) {
|
|
76
|
+
emit(cmd);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
die(`unknown command: ${cmd}\n\n${USAGE}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main(process.argv.slice(2));
|