apigrip 0.5.2 → 0.5.4

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/README.md CHANGED
@@ -100,13 +100,14 @@ apigrip mcp --project /path/to/api
100
100
  ### Shell completion
101
101
 
102
102
  ```bash
103
- # Zshcopy to your fpath
104
- cp "$(npm root -g)/apigrip/completions/_apigrip" /usr/local/share/zsh/site-functions/
105
- # or symlink into any directory in your $fpath, then:
106
- autoload -Uz compinit && compinit
103
+ # Bashadd to ~/.bashrc
104
+ eval "$(apigrip completion --shell bash)"
107
105
 
108
- # Bash
109
- apigrip completion >> ~/.bashrc
106
+ # Zsh — add to ~/.zshrc
107
+ eval "$(apigrip completion --shell zsh)"
108
+
109
+ # Auto-detects shell if --shell is omitted
110
+ eval "$(apigrip completion)"
110
111
  ```
111
112
 
112
113
  ### Exit codes
package/cli/index.js CHANGED
@@ -124,8 +124,41 @@ const cli = yargs(hideBin(process.argv))
124
124
  const { mcpCommand } = await import('./commands/mcp.js');
125
125
  await mcpCommand(argv);
126
126
  })
127
+ .command('completion', 'Generate shell completion script', (yargs) => {
128
+ return yargs
129
+ .option('shell', { type: 'string', choices: ['bash', 'zsh'], describe: 'Shell type (default: auto-detect)' });
130
+ }, (argv) => {
131
+ const shell = argv.shell || (process.env.SHELL || '').split('/').pop() || 'bash';
132
+ if (shell === 'zsh') {
133
+ console.log(`#compdef apigrip
134
+
135
+ _apigrip() {
136
+ local completions
137
+ completions=("\${(@f)$(apigrip --get-yargs-completions "\${words[@]}" 2>/dev/null)}")
138
+ compadd -a completions
139
+ }
140
+
141
+ _apigrip`);
142
+ } else {
143
+ // Let yargs generate bash completions by re-running with --get-yargs-completions
144
+ console.log(`###-begin-apigrip-completions-###
145
+ _apigrip_yargs_completions()
146
+ {
147
+ local cur_word args type_list
148
+ cur_word="\${COMP_WORDS[COMP_CWORD]}"
149
+ args=("\${COMP_WORDS[@]}")
150
+ type_list=$(apigrip --get-yargs-completions "\${args[@]}")
151
+ COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
152
+ if [ \${#COMPREPLY[@]} -eq 0 ]; then
153
+ COMPREPLY=()
154
+ fi
155
+ return 0
156
+ }
157
+ complete -o default -F _apigrip_yargs_completions apigrip
158
+ ###-end-apigrip-completions-###`);
159
+ }
160
+ })
127
161
  .demandCommand(1, 'You need at least one command')
128
162
  .strictCommands()
129
- .completion('completion', 'Generate shell completion script')
130
163
  .help()
131
164
  .argv;
@@ -1,144 +1,9 @@
1
1
  #compdef apigrip
2
2
 
3
3
  _apigrip() {
4
- local -a commands
5
- commands=(
6
- 'serve:Start the web UI server'
7
- 'send:Send an API request'
8
- 'curl:Generate curl command'
9
- 'list:List endpoints from spec'
10
- 'show:Show endpoint details'
11
- 'projects:Manage project bookmarks'
12
- 'last:Show last cached response'
13
- 'env:Manage environments'
14
- 'spec:Print the parsed OpenAPI spec'
15
- 'mcp:Start MCP server'
16
- 'completion:Generate shell completion script'
17
- )
18
-
19
- local -a global_opts
20
- global_opts=(
21
- '--help[Show help]'
22
- '--version[Show version number]'
23
- )
24
-
25
- local -a project_opts
26
- project_opts=(
27
- '--project[Project directory]:directory:_directories'
28
- '--spec[Path to spec file]:file:_files'
29
- )
30
-
31
- _arguments -C \
32
- '1:command:->command' \
33
- '*::arg:->args'
34
-
35
- case $state in
36
- command)
37
- _describe -t commands 'apigrip command' commands
38
- ;;
39
- args)
40
- case $words[1] in
41
- serve)
42
- _arguments \
43
- '--port[Port to listen on]:port' \
44
- '--host[Host to bind to]:host' \
45
- '--open[Open browser on start]' \
46
- '--no-browse[Disable directory browsing]' \
47
- $project_opts \
48
- $global_opts
49
- ;;
50
- send)
51
- _arguments \
52
- '1:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \
53
- '2:path' \
54
- '-d[Request body]:body' \
55
- '--data[Request body]:body' \
56
- '-e[Environment name]:env' \
57
- '--env[Environment name]:env' \
58
- '*--query[Query params (key=value)]:param' \
59
- '*--header[Headers (Name: value)]:header' \
60
- '*--pathParam[Path params (key=value)]:param' \
61
- '-v[Verbose output]' \
62
- '--verbose[Verbose output]' \
63
- '-i[Include headers]' \
64
- '--headers[Include headers]' \
65
- '--dry-run[Print without sending]' \
66
- '--curl[Print curl command only]' \
67
- '--filter[jq filter for response body]:filter' \
68
- $project_opts \
69
- $global_opts
70
- ;;
71
- curl)
72
- _arguments \
73
- '1:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \
74
- '2:path' \
75
- '-d[Request body]:body' \
76
- '--data[Request body]:body' \
77
- '-e[Environment name]:env' \
78
- '--env[Environment name]:env' \
79
- '*--query[Query params (key=value)]:param' \
80
- '*--header[Headers (Name: value)]:header' \
81
- '*--pathParam[Path params (key=value)]:param' \
82
- $project_opts \
83
- $global_opts
84
- ;;
85
- list)
86
- _arguments \
87
- '--tag[Filter by tag]:tag' \
88
- '--search[Search endpoints]:search' \
89
- '--json[JSON output]' \
90
- $project_opts \
91
- $global_opts
92
- ;;
93
- show)
94
- _arguments \
95
- '1:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \
96
- '2:path' \
97
- '--json[Full JSON output]' \
98
- $project_opts \
99
- $global_opts
100
- ;;
101
- projects)
102
- _arguments \
103
- '1:action:(add remove)' \
104
- '2:directory:_directories'
105
- ;;
106
- last)
107
- _arguments \
108
- '1:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \
109
- '2:path' \
110
- '--json[Full JSON output]' \
111
- '-v[Verbose output]' \
112
- '--verbose[Verbose output]' \
113
- '-i[Include headers]' \
114
- '--headers[Include headers]' \
115
- $project_opts \
116
- $global_opts
117
- ;;
118
- env)
119
- _arguments \
120
- '1:action:(show set delete import)' \
121
- '2:name' \
122
- '3:key' \
123
- '4:value' \
124
- '--import-name[Target environment name]:name' \
125
- '--merge[Merge with existing values]' \
126
- '--project[Project directory]:directory:_directories'
127
- ;;
128
- spec)
129
- _arguments \
130
- '--raw[Print raw spec file]' \
131
- $project_opts \
132
- $global_opts
133
- ;;
134
- mcp)
135
- _arguments \
136
- $project_opts \
137
- $global_opts
138
- ;;
139
- esac
140
- ;;
141
- esac
4
+ local completions
5
+ completions=("${(@f)$(apigrip --get-yargs-completions "${words[@]}" 2>/dev/null)}")
6
+ compadd -a completions
142
7
  }
143
8
 
144
9
  _apigrip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apigrip",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A spec-first, read-only OpenAPI client for developers",
5
5
  "type": "module",
6
6
  "main": "./lib/index.cjs",
@@ -21,7 +21,8 @@
21
21
  "mcp/",
22
22
  "server/",
23
23
  "client/dist/",
24
- "completions/"
24
+ "completions/",
25
+ "README.md"
25
26
  ],
26
27
  "scripts": {
27
28
  "start": "node cli/index.js serve",