@mainwp/control 1.0.0
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 +674 -0
- package/README.md +583 -0
- package/bin/_exit.js +12 -0
- package/bin/dev.js +7 -0
- package/bin/run.js +7 -0
- package/dist/chat/chat-engine.d.ts +213 -0
- package/dist/chat/chat-engine.d.ts.map +1 -0
- package/dist/chat/chat-engine.js +636 -0
- package/dist/chat/chat-engine.js.map +1 -0
- package/dist/chat/index.d.ts +10 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +14 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/providers/anthropic.d.ts +52 -0
- package/dist/chat/providers/anthropic.d.ts.map +1 -0
- package/dist/chat/providers/anthropic.js +292 -0
- package/dist/chat/providers/anthropic.js.map +1 -0
- package/dist/chat/providers/gemini.d.ts +52 -0
- package/dist/chat/providers/gemini.d.ts.map +1 -0
- package/dist/chat/providers/gemini.js +284 -0
- package/dist/chat/providers/gemini.js.map +1 -0
- package/dist/chat/providers/index.d.ts +19 -0
- package/dist/chat/providers/index.d.ts.map +1 -0
- package/dist/chat/providers/index.js +23 -0
- package/dist/chat/providers/index.js.map +1 -0
- package/dist/chat/providers/local.d.ts +37 -0
- package/dist/chat/providers/local.d.ts.map +1 -0
- package/dist/chat/providers/local.js +130 -0
- package/dist/chat/providers/local.js.map +1 -0
- package/dist/chat/providers/openai-compatible.d.ts +155 -0
- package/dist/chat/providers/openai-compatible.d.ts.map +1 -0
- package/dist/chat/providers/openai-compatible.js +264 -0
- package/dist/chat/providers/openai-compatible.js.map +1 -0
- package/dist/chat/providers/openai.d.ts +24 -0
- package/dist/chat/providers/openai.d.ts.map +1 -0
- package/dist/chat/providers/openai.js +62 -0
- package/dist/chat/providers/openai.js.map +1 -0
- package/dist/chat/providers/openrouter.d.ts +26 -0
- package/dist/chat/providers/openrouter.d.ts.map +1 -0
- package/dist/chat/providers/openrouter.js +65 -0
- package/dist/chat/providers/openrouter.js.map +1 -0
- package/dist/chat/providers/provider-fetch.d.ts +15 -0
- package/dist/chat/providers/provider-fetch.d.ts.map +1 -0
- package/dist/chat/providers/provider-fetch.js +35 -0
- package/dist/chat/providers/provider-fetch.js.map +1 -0
- package/dist/chat/providers/provider.d.ts +214 -0
- package/dist/chat/providers/provider.d.ts.map +1 -0
- package/dist/chat/providers/provider.js +166 -0
- package/dist/chat/providers/provider.js.map +1 -0
- package/dist/chat/providers/sse-reader.d.ts +21 -0
- package/dist/chat/providers/sse-reader.d.ts.map +1 -0
- package/dist/chat/providers/sse-reader.js +48 -0
- package/dist/chat/providers/sse-reader.js.map +1 -0
- package/dist/chat/system-prompt.d.ts +33 -0
- package/dist/chat/system-prompt.d.ts.map +1 -0
- package/dist/chat/system-prompt.js +166 -0
- package/dist/chat/system-prompt.js.map +1 -0
- package/dist/chat/tool-envelope.d.ts +72 -0
- package/dist/chat/tool-envelope.d.ts.map +1 -0
- package/dist/chat/tool-envelope.js +263 -0
- package/dist/chat/tool-envelope.js.map +1 -0
- package/dist/commands/abilities/info.d.ts +21 -0
- package/dist/commands/abilities/info.d.ts.map +1 -0
- package/dist/commands/abilities/info.js +80 -0
- package/dist/commands/abilities/info.js.map +1 -0
- package/dist/commands/abilities/list.d.ts +19 -0
- package/dist/commands/abilities/list.d.ts.map +1 -0
- package/dist/commands/abilities/list.js +98 -0
- package/dist/commands/abilities/list.js.map +1 -0
- package/dist/commands/abilities/run.d.ts +75 -0
- package/dist/commands/abilities/run.d.ts.map +1 -0
- package/dist/commands/abilities/run.js +468 -0
- package/dist/commands/abilities/run.js.map +1 -0
- package/dist/commands/chat.d.ts +54 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +384 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/config/show.d.ts +54 -0
- package/dist/commands/config/show.d.ts.map +1 -0
- package/dist/commands/config/show.js +324 -0
- package/dist/commands/config/show.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +412 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/jobs/watch.d.ts +50 -0
- package/dist/commands/jobs/watch.d.ts.map +1 -0
- package/dist/commands/jobs/watch.js +269 -0
- package/dist/commands/jobs/watch.js.map +1 -0
- package/dist/commands/login.d.ts +25 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +165 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/profile/delete.d.ts +22 -0
- package/dist/commands/profile/delete.d.ts.map +1 -0
- package/dist/commands/profile/delete.js +57 -0
- package/dist/commands/profile/delete.js.map +1 -0
- package/dist/commands/profile/list.d.ts +19 -0
- package/dist/commands/profile/list.d.ts.map +1 -0
- package/dist/commands/profile/list.js +53 -0
- package/dist/commands/profile/list.js.map +1 -0
- package/dist/commands/profile/use.d.ts +22 -0
- package/dist/commands/profile/use.d.ts.map +1 -0
- package/dist/commands/profile/use.js +46 -0
- package/dist/commands/profile/use.js.map +1 -0
- package/dist/config/fs-utils.d.ts +14 -0
- package/dist/config/fs-utils.d.ts.map +1 -0
- package/dist/config/fs-utils.js +31 -0
- package/dist/config/fs-utils.js.map +1 -0
- package/dist/config/keychain.d.ts +53 -0
- package/dist/config/keychain.d.ts.map +1 -0
- package/dist/config/keychain.js +175 -0
- package/dist/config/keychain.js.map +1 -0
- package/dist/config/profile-store.d.ts +85 -0
- package/dist/config/profile-store.d.ts.map +1 -0
- package/dist/config/profile-store.js +228 -0
- package/dist/config/profile-store.js.map +1 -0
- package/dist/config/settings.d.ts +71 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +151 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/abilities-executor.d.ts +126 -0
- package/dist/core/abilities-executor.d.ts.map +1 -0
- package/dist/core/abilities-executor.js +264 -0
- package/dist/core/abilities-executor.js.map +1 -0
- package/dist/core/batch-manager.d.ts +113 -0
- package/dist/core/batch-manager.d.ts.map +1 -0
- package/dist/core/batch-manager.js +244 -0
- package/dist/core/batch-manager.js.map +1 -0
- package/dist/core/http-client.d.ts +111 -0
- package/dist/core/http-client.d.ts.map +1 -0
- package/dist/core/http-client.js +329 -0
- package/dist/core/http-client.js.map +1 -0
- package/dist/core/safety-controller.d.ts +114 -0
- package/dist/core/safety-controller.d.ts.map +1 -0
- package/dist/core/safety-controller.js +229 -0
- package/dist/core/safety-controller.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +12 -0
- package/dist/hooks/command-not-found.d.ts.map +1 -0
- package/dist/hooks/command-not-found.js +58 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/base-command.d.ts +123 -0
- package/dist/lib/base-command.d.ts.map +1 -0
- package/dist/lib/base-command.js +285 -0
- package/dist/lib/base-command.js.map +1 -0
- package/dist/output/formatter.d.ts +48 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +138 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/json-envelope.d.ts +43 -0
- package/dist/output/json-envelope.d.ts.map +1 -0
- package/dist/output/json-envelope.js +73 -0
- package/dist/output/json-envelope.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +97 -0
- package/dist/utils/audit-logger.d.ts.map +1 -0
- package/dist/utils/audit-logger.js +169 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/colors.d.ts +29 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +36 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/errors.d.ts +107 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +149 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exit-codes.d.ts +21 -0
- package/dist/utils/exit-codes.d.ts.map +1 -0
- package/dist/utils/exit-codes.js +20 -0
- package/dist/utils/exit-codes.js.map +1 -0
- package/dist/utils/format.d.ts +64 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +69 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/prompt.d.ts +34 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +132 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/retry.d.ts +59 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +96 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/terminal-sanitizer.d.ts +60 -0
- package/dist/utils/terminal-sanitizer.d.ts.map +1 -0
- package/dist/utils/terminal-sanitizer.js +166 -0
- package/dist/utils/terminal-sanitizer.js.map +1 -0
- package/dist/validation/input-sanitizer.d.ts +76 -0
- package/dist/validation/input-sanitizer.d.ts.map +1 -0
- package/dist/validation/input-sanitizer.js +199 -0
- package/dist/validation/input-sanitizer.js.map +1 -0
- package/dist/validation/schema-validator.d.ts +75 -0
- package/dist/validation/schema-validator.d.ts.map +1 -0
- package/dist/validation/schema-validator.js +147 -0
- package/dist/validation/schema-validator.js.map +1 -0
- package/oclif.manifest.json +857 -0
- package/package.json +101 -0
- package/scripts/completions/README.md +221 -0
- package/scripts/completions/mainwpcontrol.bash +193 -0
- package/scripts/completions/mainwpcontrol.zsh +267 -0
- package/scripts/completions/profile-completer.sh +35 -0
- package/scripts/completions/regenerate.sh +78 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
#compdef mainwpcontrol
|
|
2
|
+
# mainwpcontrol zsh completion script
|
|
3
|
+
#
|
|
4
|
+
# Installation:
|
|
5
|
+
# source /path/to/mainwpcontrol/scripts/completions/mainwpcontrol.zsh
|
|
6
|
+
#
|
|
7
|
+
# Or add to ~/.zshrc:
|
|
8
|
+
# source /path/to/mainwpcontrol/scripts/completions/mainwpcontrol.zsh
|
|
9
|
+
|
|
10
|
+
# Determine the directory where this script is located
|
|
11
|
+
_MAINWPCTL_COMPLETION_DIR="${0:A:h}"
|
|
12
|
+
|
|
13
|
+
# Source the profile completer helper
|
|
14
|
+
if [[ -f "${_MAINWPCTL_COMPLETION_DIR}/profile-completer.sh" ]]; then
|
|
15
|
+
source "${_MAINWPCTL_COMPLETION_DIR}/profile-completer.sh"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Helper function to get profile names for completion
|
|
19
|
+
_mainwpcontrol_profiles() {
|
|
20
|
+
local profiles
|
|
21
|
+
if (( $+functions[_mainwpcontrol_get_profiles] )); then
|
|
22
|
+
profiles=("${(@f)$(_mainwpcontrol_get_profiles)}")
|
|
23
|
+
_describe -t profiles 'profile' profiles
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Main completion function
|
|
28
|
+
_mainwpcontrol() {
|
|
29
|
+
local curcontext="$curcontext" state line
|
|
30
|
+
typeset -A opt_args
|
|
31
|
+
|
|
32
|
+
# Common flags available on all commands
|
|
33
|
+
local -a common_flags
|
|
34
|
+
common_flags=(
|
|
35
|
+
'--debug[Show debug output]'
|
|
36
|
+
'--help[Show help]'
|
|
37
|
+
'--json[Output JSON (for scripting/CI)]'
|
|
38
|
+
'(-p --profile)'{-p,--profile}'[Use a specific profile]:profile:_mainwpcontrol_profiles'
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Top-level commands
|
|
42
|
+
local -a commands
|
|
43
|
+
commands=(
|
|
44
|
+
'abilities:Manage and execute abilities'
|
|
45
|
+
'autocomplete:Display autocomplete installation instructions'
|
|
46
|
+
'chat:Interactive chat mode for MainWP Dashboard management'
|
|
47
|
+
'doctor:Check configuration and connectivity'
|
|
48
|
+
'help:Display help for a command'
|
|
49
|
+
'jobs:Manage batch jobs'
|
|
50
|
+
'login:Authenticate with a MainWP Dashboard'
|
|
51
|
+
'profile:Manage connection profiles'
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
_arguments -C \
|
|
55
|
+
$common_flags \
|
|
56
|
+
'1: :->command' \
|
|
57
|
+
'*:: :->args'
|
|
58
|
+
|
|
59
|
+
case "$state" in
|
|
60
|
+
command)
|
|
61
|
+
_describe -t commands 'mainwpcontrol commands' commands
|
|
62
|
+
;;
|
|
63
|
+
args)
|
|
64
|
+
case "$words[1]" in
|
|
65
|
+
abilities)
|
|
66
|
+
_mainwpcontrol_abilities
|
|
67
|
+
;;
|
|
68
|
+
autocomplete)
|
|
69
|
+
_mainwpcontrol_autocomplete
|
|
70
|
+
;;
|
|
71
|
+
chat)
|
|
72
|
+
_mainwpcontrol_chat
|
|
73
|
+
;;
|
|
74
|
+
doctor)
|
|
75
|
+
_mainwpcontrol_doctor
|
|
76
|
+
;;
|
|
77
|
+
help)
|
|
78
|
+
_mainwpcontrol_help
|
|
79
|
+
;;
|
|
80
|
+
jobs)
|
|
81
|
+
_mainwpcontrol_jobs
|
|
82
|
+
;;
|
|
83
|
+
login)
|
|
84
|
+
_mainwpcontrol_login
|
|
85
|
+
;;
|
|
86
|
+
profile)
|
|
87
|
+
_mainwpcontrol_profile
|
|
88
|
+
;;
|
|
89
|
+
esac
|
|
90
|
+
;;
|
|
91
|
+
esac
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Abilities command completions
|
|
95
|
+
_mainwpcontrol_abilities() {
|
|
96
|
+
local -a subcommands
|
|
97
|
+
subcommands=(
|
|
98
|
+
'info:Get detailed information about an ability'
|
|
99
|
+
'list:List available abilities'
|
|
100
|
+
'run:Execute an ability'
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
_arguments -C \
|
|
104
|
+
$common_flags \
|
|
105
|
+
'1: :->subcommand' \
|
|
106
|
+
'*:: :->args'
|
|
107
|
+
|
|
108
|
+
case "$state" in
|
|
109
|
+
subcommand)
|
|
110
|
+
_describe -t commands 'abilities subcommands' subcommands
|
|
111
|
+
;;
|
|
112
|
+
args)
|
|
113
|
+
case "$words[1]" in
|
|
114
|
+
info)
|
|
115
|
+
_arguments \
|
|
116
|
+
$common_flags \
|
|
117
|
+
'1:ability name:'
|
|
118
|
+
;;
|
|
119
|
+
list)
|
|
120
|
+
_arguments \
|
|
121
|
+
$common_flags \
|
|
122
|
+
'--category[Filter by category]:category:(sites clients updates plugins themes core tags batch)'
|
|
123
|
+
;;
|
|
124
|
+
run)
|
|
125
|
+
_arguments \
|
|
126
|
+
$common_flags \
|
|
127
|
+
'(-i --input)'{-i,--input}'[Input parameters as JSON]:input:' \
|
|
128
|
+
'--dry-run[Preview changes without executing]' \
|
|
129
|
+
'--confirm[Execute destructive ability (after preview)]' \
|
|
130
|
+
'--force[Skip confirmation prompt (use with --confirm)]' \
|
|
131
|
+
'1:ability name:'
|
|
132
|
+
;;
|
|
133
|
+
esac
|
|
134
|
+
;;
|
|
135
|
+
esac
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Autocomplete command completions
|
|
139
|
+
_mainwpcontrol_autocomplete() {
|
|
140
|
+
_arguments \
|
|
141
|
+
'1:shell:(bash zsh)'
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
# Chat command completions
|
|
145
|
+
_mainwpcontrol_chat() {
|
|
146
|
+
_arguments \
|
|
147
|
+
$common_flags \
|
|
148
|
+
'--provider[LLM provider]:provider:(anthropic gemini local openai openrouter)' \
|
|
149
|
+
'(-m --model)'{-m,--model}'[Model to use]:model:' \
|
|
150
|
+
'--api-key[LLM API key (overrides environment)]:api key:' \
|
|
151
|
+
'--base-url[Custom API base URL]:url:' \
|
|
152
|
+
'--max-turns[Maximum tool calls per turn]:turns:' \
|
|
153
|
+
'--max-context-messages[Maximum messages to keep in context]:messages:' \
|
|
154
|
+
'--stream[Enable streaming responses]' \
|
|
155
|
+
'--no-stream[Disable streaming responses]' \
|
|
156
|
+
'1:message:'
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
# Doctor command completions
|
|
160
|
+
_mainwpcontrol_doctor() {
|
|
161
|
+
_arguments \
|
|
162
|
+
$common_flags \
|
|
163
|
+
'(-v --verbose)'{-v,--verbose}'[Verbose output]'
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
# Help command completions
|
|
167
|
+
_mainwpcontrol_help() {
|
|
168
|
+
local -a commands
|
|
169
|
+
commands=(
|
|
170
|
+
'abilities'
|
|
171
|
+
'autocomplete'
|
|
172
|
+
'chat'
|
|
173
|
+
'doctor'
|
|
174
|
+
'help'
|
|
175
|
+
'jobs'
|
|
176
|
+
'login'
|
|
177
|
+
'profile'
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
_arguments \
|
|
181
|
+
'1:command:($commands)'
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# Jobs command completions
|
|
185
|
+
_mainwpcontrol_jobs() {
|
|
186
|
+
local -a subcommands
|
|
187
|
+
subcommands=(
|
|
188
|
+
'watch:Monitor a batch job'
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
_arguments -C \
|
|
192
|
+
$common_flags \
|
|
193
|
+
'1: :->subcommand' \
|
|
194
|
+
'*:: :->args'
|
|
195
|
+
|
|
196
|
+
case "$state" in
|
|
197
|
+
subcommand)
|
|
198
|
+
_describe -t commands 'jobs subcommands' subcommands
|
|
199
|
+
;;
|
|
200
|
+
args)
|
|
201
|
+
case "$words[1]" in
|
|
202
|
+
watch)
|
|
203
|
+
_arguments \
|
|
204
|
+
$common_flags \
|
|
205
|
+
'--timeout[Maximum time to wait in seconds]:seconds:' \
|
|
206
|
+
'--initial-delay[Initial polling delay in seconds]:seconds:' \
|
|
207
|
+
'--max-delay[Maximum polling delay in seconds]:seconds:' \
|
|
208
|
+
'--no-progress[Disable progress output]' \
|
|
209
|
+
'1:job id:'
|
|
210
|
+
;;
|
|
211
|
+
esac
|
|
212
|
+
;;
|
|
213
|
+
esac
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# Login command completions
|
|
217
|
+
_mainwpcontrol_login() {
|
|
218
|
+
_arguments \
|
|
219
|
+
$common_flags \
|
|
220
|
+
'(-u --url)'{-u,--url}'[Dashboard URL]:url:' \
|
|
221
|
+
'--username[WordPress admin username]:username:' \
|
|
222
|
+
'--password[Application password]:password:' \
|
|
223
|
+
'(-n --name)'{-n,--name}'[Profile name]:name:' \
|
|
224
|
+
'--skip-ssl-verify[Skip SSL certificate verification]'
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
# Profile command completions
|
|
228
|
+
_mainwpcontrol_profile() {
|
|
229
|
+
local -a subcommands
|
|
230
|
+
subcommands=(
|
|
231
|
+
'delete:Delete a profile'
|
|
232
|
+
'list:List all profiles'
|
|
233
|
+
'use:Switch active profile'
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
_arguments -C \
|
|
237
|
+
$common_flags \
|
|
238
|
+
'1: :->subcommand' \
|
|
239
|
+
'*:: :->args'
|
|
240
|
+
|
|
241
|
+
case "$state" in
|
|
242
|
+
subcommand)
|
|
243
|
+
_describe -t commands 'profile subcommands' subcommands
|
|
244
|
+
;;
|
|
245
|
+
args)
|
|
246
|
+
case "$words[1]" in
|
|
247
|
+
delete)
|
|
248
|
+
_arguments \
|
|
249
|
+
$common_flags \
|
|
250
|
+
'1:profile name:_mainwpcontrol_profiles'
|
|
251
|
+
;;
|
|
252
|
+
list)
|
|
253
|
+
_arguments \
|
|
254
|
+
$common_flags
|
|
255
|
+
;;
|
|
256
|
+
use)
|
|
257
|
+
_arguments \
|
|
258
|
+
$common_flags \
|
|
259
|
+
'1:profile name:_mainwpcontrol_profiles'
|
|
260
|
+
;;
|
|
261
|
+
esac
|
|
262
|
+
;;
|
|
263
|
+
esac
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
# Register the completion function
|
|
267
|
+
compdef _mainwpcontrol mainwpcontrol
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# profile-completer.sh - Helper script to get available mainwpcontrol profile names
|
|
3
|
+
# This script is sourced by shell completion scripts to provide dynamic profile completion.
|
|
4
|
+
#
|
|
5
|
+
# Usage: source this file, then call _mainwpcontrol_get_profiles
|
|
6
|
+
#
|
|
7
|
+
# Returns profile names one per line, empty if no profiles exist or config is missing.
|
|
8
|
+
|
|
9
|
+
_mainwpcontrol_get_profiles() {
|
|
10
|
+
local config_file="${XDG_CONFIG_HOME:-$HOME/.config}/mainwpcontrol/profiles.json"
|
|
11
|
+
|
|
12
|
+
# Exit silently if config file doesn't exist
|
|
13
|
+
if [ ! -f "$config_file" ]; then
|
|
14
|
+
return 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Try jq first (most reliable JSON parsing)
|
|
18
|
+
if command -v jq >/dev/null 2>&1; then
|
|
19
|
+
jq -r '.profiles | keys[]' "$config_file" 2>/dev/null
|
|
20
|
+
return 0
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Fallback: use grep/sed for simple JSON parsing
|
|
24
|
+
# This handles: {"profiles":{"name1":{...},"name2":{...}}}
|
|
25
|
+
# Extract keys after "profiles": and before their values
|
|
26
|
+
grep -o '"profiles"[[:space:]]*:[[:space:]]*{[^}]*}' "$config_file" 2>/dev/null | \
|
|
27
|
+
grep -o '"[^"]*"[[:space:]]*:' | \
|
|
28
|
+
sed 's/"//g; s/[[:space:]]*://g' | \
|
|
29
|
+
grep -v '^profiles$' 2>/dev/null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# If called directly (not sourced), output profile names
|
|
33
|
+
if [ "${0##*/}" = "profile-completer.sh" ]; then
|
|
34
|
+
_mainwpcontrol_get_profiles
|
|
35
|
+
fi
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# regenerate.sh - Regenerate shell completion scripts for mainwpcontrol
|
|
3
|
+
#
|
|
4
|
+
# This script helps developers update completion scripts after CLI changes.
|
|
5
|
+
# Run this after adding, removing, or modifying commands or flags.
|
|
6
|
+
#
|
|
7
|
+
# Usage: ./scripts/completions/regenerate.sh
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
13
|
+
|
|
14
|
+
echo "Shell Completion Regeneration Helper"
|
|
15
|
+
echo "====================================="
|
|
16
|
+
echo ""
|
|
17
|
+
echo "The mainwpcontrol completion scripts are manually maintained to provide"
|
|
18
|
+
echo "optimal completion behavior with dynamic profile name completion."
|
|
19
|
+
echo ""
|
|
20
|
+
echo "After adding, removing, or modifying commands/flags, you should update:"
|
|
21
|
+
echo ""
|
|
22
|
+
echo " 1. $SCRIPT_DIR/mainwpcontrol.bash"
|
|
23
|
+
echo " - Update 'commands' variable for new top-level commands"
|
|
24
|
+
echo " - Update '*_commands' variables for new subcommands"
|
|
25
|
+
echo " - Update '*_flags' variables for new flags"
|
|
26
|
+
echo ""
|
|
27
|
+
echo " 2. $SCRIPT_DIR/mainwpcontrol.zsh"
|
|
28
|
+
echo " - Update 'commands' array for new top-level commands"
|
|
29
|
+
echo " - Update subcommand arrays in respective functions"
|
|
30
|
+
echo " - Update _arguments calls for new flags"
|
|
31
|
+
echo ""
|
|
32
|
+
echo "Testing completions:"
|
|
33
|
+
echo " # Bash"
|
|
34
|
+
echo " source $SCRIPT_DIR/mainwpcontrol.bash"
|
|
35
|
+
echo " mainwpcontrol <TAB>"
|
|
36
|
+
echo ""
|
|
37
|
+
echo " # Zsh"
|
|
38
|
+
echo " source $SCRIPT_DIR/mainwpcontrol.zsh"
|
|
39
|
+
echo " mainwpcontrol <TAB>"
|
|
40
|
+
echo ""
|
|
41
|
+
|
|
42
|
+
# Verify files exist
|
|
43
|
+
echo "Checking completion files..."
|
|
44
|
+
|
|
45
|
+
if [[ -f "$SCRIPT_DIR/mainwpcontrol.bash" ]]; then
|
|
46
|
+
echo " [OK] mainwpcontrol.bash"
|
|
47
|
+
else
|
|
48
|
+
echo " [MISSING] mainwpcontrol.bash"
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [[ -f "$SCRIPT_DIR/mainwpcontrol.zsh" ]]; then
|
|
52
|
+
echo " [OK] mainwpcontrol.zsh"
|
|
53
|
+
else
|
|
54
|
+
echo " [MISSING] mainwpcontrol.zsh"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
if [[ -f "$SCRIPT_DIR/profile-completer.sh" ]]; then
|
|
58
|
+
echo " [OK] profile-completer.sh"
|
|
59
|
+
else
|
|
60
|
+
echo " [MISSING] profile-completer.sh"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
echo ""
|
|
64
|
+
echo "Extracting current CLI structure..."
|
|
65
|
+
echo ""
|
|
66
|
+
|
|
67
|
+
# Try to extract commands from the built CLI
|
|
68
|
+
if [[ -x "$PROJECT_ROOT/bin/run.js" ]]; then
|
|
69
|
+
echo "Top-level commands:"
|
|
70
|
+
"$PROJECT_ROOT/bin/run.js" --help 2>/dev/null | grep -E '^\s+[a-z]+\s' | awk '{print " - " $1}' || echo " (could not extract)"
|
|
71
|
+
echo ""
|
|
72
|
+
else
|
|
73
|
+
echo "Note: Build the project first to extract command structure:"
|
|
74
|
+
echo " npm run build"
|
|
75
|
+
echo ""
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "Done. Remember to commit your changes after updating completion scripts."
|