@switchbot/openapi-cli 3.1.0 → 3.2.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.
Files changed (113) hide show
  1. package/README.md +34 -42
  2. package/dist/index.js +56945 -169
  3. package/dist/policy/schema/v0.2.json +1 -1
  4. package/package.json +3 -2
  5. package/dist/api/client.js +0 -235
  6. package/dist/auth.js +0 -20
  7. package/dist/commands/agent-bootstrap.js +0 -182
  8. package/dist/commands/auth.js +0 -354
  9. package/dist/commands/batch.js +0 -413
  10. package/dist/commands/cache.js +0 -126
  11. package/dist/commands/capabilities.js +0 -385
  12. package/dist/commands/catalog.js +0 -359
  13. package/dist/commands/completion.js +0 -385
  14. package/dist/commands/config.js +0 -376
  15. package/dist/commands/daemon.js +0 -367
  16. package/dist/commands/device-meta.js +0 -159
  17. package/dist/commands/devices.js +0 -948
  18. package/dist/commands/doctor.js +0 -1015
  19. package/dist/commands/events.js +0 -563
  20. package/dist/commands/expand.js +0 -130
  21. package/dist/commands/explain.js +0 -139
  22. package/dist/commands/health.js +0 -113
  23. package/dist/commands/history.js +0 -320
  24. package/dist/commands/identity.js +0 -59
  25. package/dist/commands/install.js +0 -246
  26. package/dist/commands/mcp.js +0 -2017
  27. package/dist/commands/plan.js +0 -653
  28. package/dist/commands/policy.js +0 -586
  29. package/dist/commands/quota.js +0 -78
  30. package/dist/commands/rules.js +0 -875
  31. package/dist/commands/scenes.js +0 -264
  32. package/dist/commands/schema.js +0 -177
  33. package/dist/commands/status-sync.js +0 -131
  34. package/dist/commands/uninstall.js +0 -237
  35. package/dist/commands/upgrade-check.js +0 -88
  36. package/dist/commands/watch.js +0 -194
  37. package/dist/commands/webhook.js +0 -182
  38. package/dist/config.js +0 -258
  39. package/dist/credentials/backends/file.js +0 -101
  40. package/dist/credentials/backends/linux.js +0 -129
  41. package/dist/credentials/backends/macos.js +0 -129
  42. package/dist/credentials/backends/windows.js +0 -215
  43. package/dist/credentials/keychain.js +0 -88
  44. package/dist/credentials/prime.js +0 -52
  45. package/dist/devices/cache.js +0 -293
  46. package/dist/devices/catalog.js +0 -767
  47. package/dist/devices/device-meta.js +0 -56
  48. package/dist/devices/history-agg.js +0 -138
  49. package/dist/devices/history-query.js +0 -181
  50. package/dist/devices/param-validator.js +0 -433
  51. package/dist/devices/resources.js +0 -270
  52. package/dist/install/default-steps.js +0 -257
  53. package/dist/install/preflight.js +0 -212
  54. package/dist/install/steps.js +0 -67
  55. package/dist/lib/command-keywords.js +0 -17
  56. package/dist/lib/daemon-state.js +0 -46
  57. package/dist/lib/destructive-mode.js +0 -12
  58. package/dist/lib/devices.js +0 -382
  59. package/dist/lib/idempotency.js +0 -106
  60. package/dist/lib/plan-store.js +0 -68
  61. package/dist/lib/request-context.js +0 -12
  62. package/dist/lib/scenes.js +0 -10
  63. package/dist/logger.js +0 -16
  64. package/dist/mcp/device-history.js +0 -145
  65. package/dist/mcp/events-subscription.js +0 -213
  66. package/dist/mqtt/client.js +0 -180
  67. package/dist/mqtt/credential.js +0 -30
  68. package/dist/policy/add-rule.js +0 -124
  69. package/dist/policy/diff.js +0 -91
  70. package/dist/policy/format.js +0 -57
  71. package/dist/policy/load.js +0 -61
  72. package/dist/policy/migrate.js +0 -67
  73. package/dist/policy/schema.js +0 -18
  74. package/dist/policy/validate.js +0 -262
  75. package/dist/rules/action.js +0 -205
  76. package/dist/rules/audit-query.js +0 -89
  77. package/dist/rules/conflict-analyzer.js +0 -203
  78. package/dist/rules/cron-scheduler.js +0 -186
  79. package/dist/rules/destructive.js +0 -52
  80. package/dist/rules/engine.js +0 -757
  81. package/dist/rules/matcher.js +0 -230
  82. package/dist/rules/pid-file.js +0 -95
  83. package/dist/rules/quiet-hours.js +0 -45
  84. package/dist/rules/suggest.js +0 -95
  85. package/dist/rules/throttle.js +0 -116
  86. package/dist/rules/types.js +0 -34
  87. package/dist/rules/webhook-listener.js +0 -223
  88. package/dist/rules/webhook-token.js +0 -90
  89. package/dist/schema/field-aliases.js +0 -131
  90. package/dist/sinks/dispatcher.js +0 -12
  91. package/dist/sinks/file.js +0 -19
  92. package/dist/sinks/format.js +0 -56
  93. package/dist/sinks/homeassistant.js +0 -44
  94. package/dist/sinks/openclaw.js +0 -33
  95. package/dist/sinks/stdout.js +0 -5
  96. package/dist/sinks/telegram.js +0 -28
  97. package/dist/sinks/types.js +0 -1
  98. package/dist/sinks/webhook.js +0 -22
  99. package/dist/status-sync/manager.js +0 -268
  100. package/dist/utils/arg-parsers.js +0 -66
  101. package/dist/utils/audit.js +0 -117
  102. package/dist/utils/filter.js +0 -189
  103. package/dist/utils/flags.js +0 -186
  104. package/dist/utils/format.js +0 -117
  105. package/dist/utils/health.js +0 -101
  106. package/dist/utils/help-json.js +0 -54
  107. package/dist/utils/name-resolver.js +0 -137
  108. package/dist/utils/output.js +0 -404
  109. package/dist/utils/quota.js +0 -227
  110. package/dist/utils/redact.js +0 -68
  111. package/dist/utils/retry.js +0 -140
  112. package/dist/utils/string.js +0 -22
  113. package/dist/version.js +0 -4
@@ -1,385 +0,0 @@
1
- const BASH_SCRIPT = `# switchbot bash completion
2
- # Install: source <(switchbot completion bash)
3
- # Or add to ~/.bashrc:
4
- # source <(switchbot completion bash)
5
-
6
- _switchbot_completion() {
7
- local cur prev words cword
8
- _get_comp_words_by_ref -n : cur prev words cword 2>/dev/null || {
9
- cur="\${COMP_WORDS[COMP_CWORD]}"
10
- prev="\${COMP_WORDS[COMP_CWORD-1]}"
11
- words=("\${COMP_WORDS[@]}")
12
- cword="\${COMP_CWORD}"
13
- }
14
-
15
- local top_cmds="config devices scenes webhook completion mcp quota catalog cache events doctor schema history plan capabilities help"
16
- local config_sub="set-token show list-profiles"
17
- local devices_sub="list ls status command types commands describe batch watch explain expand meta"
18
- local scenes_sub="list execute"
19
- local webhook_sub="setup query update delete"
20
- local events_sub="tail mqtt-tail"
21
- local quota_sub="status reset"
22
- local catalog_sub="path show diff refresh"
23
- local cache_sub="show clear"
24
- local history_sub="show replay"
25
- local plan_sub="schema validate run"
26
- local completion_shells="bash zsh fish powershell"
27
- local global_opts="--json --format --fields --verbose -v --dry-run --timeout --retry-on-429 --backoff --no-retry --no-quota --cache --no-cache --config --profile --audit-log --audit-log-path --help -h --version -V"
28
-
29
- if [[ \${cword} -eq 1 ]]; then
30
- COMPREPLY=( $(compgen -W "\${top_cmds} \${global_opts}" -- "\${cur}") )
31
- return
32
- fi
33
-
34
- case "\${words[1]}" in
35
- config)
36
- if [[ \${cword} -eq 2 ]]; then
37
- COMPREPLY=( $(compgen -W "\${config_sub}" -- "\${cur}") )
38
- fi
39
- ;;
40
- devices)
41
- if [[ \${cword} -eq 2 ]]; then
42
- COMPREPLY=( $(compgen -W "\${devices_sub}" -- "\${cur}") )
43
- elif [[ "\${words[2]}" == "command" && "\${prev}" == "--type" ]]; then
44
- COMPREPLY=( $(compgen -W "command customize" -- "\${cur}") )
45
- fi
46
- ;;
47
- scenes)
48
- if [[ \${cword} -eq 2 ]]; then
49
- COMPREPLY=( $(compgen -W "\${scenes_sub}" -- "\${cur}") )
50
- fi
51
- ;;
52
- events)
53
- if [[ \${cword} -eq 2 ]]; then
54
- COMPREPLY=( $(compgen -W "\${events_sub}" -- "\${cur}") )
55
- fi
56
- ;;
57
- quota)
58
- if [[ \${cword} -eq 2 ]]; then
59
- COMPREPLY=( $(compgen -W "\${quota_sub}" -- "\${cur}") )
60
- fi
61
- ;;
62
- catalog)
63
- if [[ \${cword} -eq 2 ]]; then
64
- COMPREPLY=( $(compgen -W "\${catalog_sub}" -- "\${cur}") )
65
- fi
66
- ;;
67
- cache)
68
- if [[ \${cword} -eq 2 ]]; then
69
- COMPREPLY=( $(compgen -W "\${cache_sub}" -- "\${cur}") )
70
- fi
71
- ;;
72
- history)
73
- if [[ \${cword} -eq 2 ]]; then
74
- COMPREPLY=( $(compgen -W "\${history_sub}" -- "\${cur}") )
75
- fi
76
- ;;
77
- plan)
78
- if [[ \${cword} -eq 2 ]]; then
79
- COMPREPLY=( $(compgen -W "\${plan_sub}" -- "\${cur}") )
80
- fi
81
- ;;
82
- webhook)
83
- if [[ \${cword} -eq 2 ]]; then
84
- COMPREPLY=( $(compgen -W "\${webhook_sub}" -- "\${cur}") )
85
- elif [[ "\${words[2]}" == "update" ]]; then
86
- COMPREPLY=( $(compgen -W "--enable --disable \${global_opts}" -- "\${cur}") )
87
- fi
88
- ;;
89
- completion)
90
- if [[ \${cword} -eq 2 ]]; then
91
- COMPREPLY=( $(compgen -W "\${completion_shells}" -- "\${cur}") )
92
- fi
93
- ;;
94
- *)
95
- COMPREPLY=( $(compgen -W "\${global_opts}" -- "\${cur}") )
96
- ;;
97
- esac
98
- }
99
-
100
- complete -F _switchbot_completion switchbot
101
- `;
102
- const ZSH_SCRIPT = `# switchbot zsh completion
103
- # Install: source <(switchbot completion zsh)
104
- # Or add to ~/.zshrc:
105
- # source <(switchbot completion zsh)
106
-
107
- _switchbot() {
108
- local -a top_cmds config_sub devices_sub scenes_sub webhook_sub events_sub quota_sub catalog_sub cache_sub history_sub plan_sub completion_shells
109
- top_cmds=(
110
- 'config:Manage API credentials'
111
- 'devices:List and control devices'
112
- 'scenes:List and execute scenes'
113
- 'webhook:Manage webhook configuration'
114
- 'completion:Print a shell completion script'
115
- 'mcp:Run the MCP server'
116
- 'quota:Inspect local request quota'
117
- 'catalog:Inspect the built-in device catalog'
118
- 'cache:Inspect local caches'
119
- 'events:Receive webhook or MQTT events'
120
- 'doctor:Run self-checks'
121
- 'schema:Export the device catalog as JSON'
122
- 'history:View and replay audited commands'
123
- 'plan:Validate and run batch plans'
124
- 'capabilities:Print a machine-readable manifest'
125
- 'help:Show help for a command'
126
- )
127
- config_sub=('set-token:Save token + secret' 'show:Show current credential source' 'list-profiles:List named credential profiles')
128
- devices_sub=(
129
- 'list:List all devices'
130
- 'ls:Alias for list'
131
- 'status:Query device status'
132
- 'command:Send a control command'
133
- 'types:List known device types (offline)'
134
- 'commands:Show commands for a device type (offline)'
135
- 'describe:Show metadata + supported commands for one device'
136
- 'batch:Send one command to many devices'
137
- 'watch:Poll device status and emit changes'
138
- 'explain:One-shot device summary'
139
- 'expand:Build wire-format params from semantic flags'
140
- 'meta:Manage local device metadata'
141
- )
142
- scenes_sub=('list:List manual scenes' 'execute:Run a scene')
143
- webhook_sub=(
144
- 'setup:Register a webhook URL'
145
- 'query:Query configured webhooks'
146
- 'update:Enable/disable a webhook'
147
- 'delete:Delete a webhook'
148
- )
149
- events_sub=('tail:Run a local webhook receiver' 'mqtt-tail:Stream MQTT shadow events')
150
- quota_sub=('status:Show today and recent quota usage' 'reset:Delete the local quota counter')
151
- catalog_sub=('path:Show overlay path' 'show:Show built-in/overlay/effective catalog' 'diff:Show overlay changes' 'refresh:Clear overlay cache')
152
- cache_sub=('show:Summarize cache files' 'clear:Delete cache files')
153
- history_sub=('show:Print recent audit entries' 'replay:Re-run one audited command')
154
- plan_sub=('schema:Print the plan schema' 'validate:Validate a plan file' 'run:Validate and execute a plan')
155
- completion_shells=('bash' 'zsh' 'fish' 'powershell')
156
-
157
- local global_opts
158
- global_opts=(
159
- '--json[Raw JSON output]'
160
- '--format[Output format]:type:(table json jsonl tsv yaml id)'
161
- '--fields[Comma-separated output columns]:csv:'
162
- '(-v --verbose)'{-v,--verbose}'[Log HTTP details to stderr]'
163
- '--dry-run[Print mutating requests without sending]'
164
- '--timeout[HTTP timeout in ms]:ms:'
165
- '--retry-on-429[Max 429 retries]:n:'
166
- '--backoff[Retry backoff strategy]:strategy:(linear exponential)'
167
- '--no-retry[Disable 429 retries]'
168
- '--no-quota[Disable the local quota counter]'
169
- '--cache[Cache mode]:mode:'
170
- '--no-cache[Disable cache reads]'
171
- '--config[Override credential file path]:path:_files'
172
- '--profile[Use a named credential profile]:name:'
173
- '--audit-log[Append mutating commands to ~/.switchbot/audit.log]'
174
- '--audit-log-path[Custom audit log file path]:path:_files'
175
- '(-h --help)'{-h,--help}'[Show help]'
176
- '(-V --version)'{-V,--version}'[Show version]'
177
- )
178
-
179
- _arguments -C \\
180
- "1:command:->top" \\
181
- "2:subcommand:->sub" \\
182
- "*::arg:->rest" \\
183
- $global_opts
184
-
185
- case "$state" in
186
- top)
187
- _describe 'command' top_cmds
188
- ;;
189
- sub)
190
- case "$words[2]" in
191
- config) _describe 'config' config_sub ;;
192
- devices) _describe 'devices' devices_sub ;;
193
- scenes) _describe 'scenes' scenes_sub ;;
194
- webhook) _describe 'webhook' webhook_sub ;;
195
- events) _describe 'events' events_sub ;;
196
- quota) _describe 'quota' quota_sub ;;
197
- catalog) _describe 'catalog' catalog_sub ;;
198
- cache) _describe 'cache' cache_sub ;;
199
- history) _describe 'history' history_sub ;;
200
- plan) _describe 'plan' plan_sub ;;
201
- completion) _values 'shell' $completion_shells ;;
202
- esac
203
- ;;
204
- rest)
205
- if [[ "$words[2]" == "webhook" && "$words[3]" == "update" ]]; then
206
- _values 'flag' '--enable' '--disable'
207
- fi
208
- ;;
209
- esac
210
- }
211
-
212
- compdef _switchbot switchbot
213
- `;
214
- const FISH_SCRIPT = `# switchbot fish completion
215
- # Install:
216
- # switchbot completion fish > ~/.config/fish/completions/switchbot.fish
217
-
218
- complete -c switchbot -f
219
-
220
- # Global options
221
- complete -c switchbot -l json -d 'Raw JSON output'
222
- complete -c switchbot -l format -r -d 'Output format'
223
- complete -c switchbot -l fields -r -d 'Comma-separated output columns'
224
- complete -c switchbot -s v -l verbose -d 'Log HTTP details to stderr'
225
- complete -c switchbot -l dry-run -d 'Print mutating requests without sending'
226
- complete -c switchbot -l timeout -r -d 'HTTP timeout in ms'
227
- complete -c switchbot -l retry-on-429 -r -d 'Max 429 retries'
228
- complete -c switchbot -l backoff -r -d 'Retry backoff strategy'
229
- complete -c switchbot -l no-retry -d 'Disable 429 retries'
230
- complete -c switchbot -l no-quota -d 'Disable the local quota counter'
231
- complete -c switchbot -l cache -r -d 'Cache mode'
232
- complete -c switchbot -l no-cache -d 'Disable cache reads'
233
- complete -c switchbot -l config -r -d 'Credential file path'
234
- complete -c switchbot -l profile -r -d 'Named credential profile'
235
- complete -c switchbot -l audit-log -d 'Append mutating commands to audit log'
236
- complete -c switchbot -l audit-log-path -r -d 'Custom audit log file path'
237
- complete -c switchbot -s h -l help -d 'Show help'
238
- complete -c switchbot -s V -l version -d 'Show version'
239
-
240
- # Top-level commands
241
- complete -c switchbot -n '__fish_use_subcommand' -a 'config' -d 'Manage API credentials'
242
- complete -c switchbot -n '__fish_use_subcommand' -a 'devices' -d 'List and control devices'
243
- complete -c switchbot -n '__fish_use_subcommand' -a 'scenes' -d 'List and execute scenes'
244
- complete -c switchbot -n '__fish_use_subcommand' -a 'webhook' -d 'Manage webhook configuration'
245
- complete -c switchbot -n '__fish_use_subcommand' -a 'completion' -d 'Print a shell completion script'
246
- complete -c switchbot -n '__fish_use_subcommand' -a 'mcp' -d 'Run the MCP server'
247
- complete -c switchbot -n '__fish_use_subcommand' -a 'quota' -d 'Inspect local request quota'
248
- complete -c switchbot -n '__fish_use_subcommand' -a 'catalog' -d 'Inspect the built-in device catalog'
249
- complete -c switchbot -n '__fish_use_subcommand' -a 'cache' -d 'Inspect local caches'
250
- complete -c switchbot -n '__fish_use_subcommand' -a 'events' -d 'Receive webhook or MQTT events'
251
- complete -c switchbot -n '__fish_use_subcommand' -a 'doctor' -d 'Run self-checks'
252
- complete -c switchbot -n '__fish_use_subcommand' -a 'schema' -d 'Export the device catalog as JSON'
253
- complete -c switchbot -n '__fish_use_subcommand' -a 'history' -d 'View and replay audited commands'
254
- complete -c switchbot -n '__fish_use_subcommand' -a 'plan' -d 'Validate and run batch plans'
255
- complete -c switchbot -n '__fish_use_subcommand' -a 'capabilities' -d 'Print a machine-readable manifest'
256
- complete -c switchbot -n '__fish_use_subcommand' -a 'help' -d 'Show help'
257
-
258
- # config
259
- complete -c switchbot -n '__fish_seen_subcommand_from config' -a 'set-token show list-profiles'
260
-
261
- # devices
262
- complete -c switchbot -n '__fish_seen_subcommand_from devices' -a 'list ls status command types commands describe batch watch explain expand meta'
263
-
264
- # scenes
265
- complete -c switchbot -n '__fish_seen_subcommand_from scenes' -a 'list execute'
266
-
267
- # webhook
268
- complete -c switchbot -n '__fish_seen_subcommand_from webhook' -a 'setup query update delete'
269
- complete -c switchbot -n '__fish_seen_subcommand_from webhook; and __fish_seen_subcommand_from update' -l enable -d 'Enable the webhook'
270
- complete -c switchbot -n '__fish_seen_subcommand_from webhook; and __fish_seen_subcommand_from update' -l disable -d 'Disable the webhook'
271
-
272
- # events
273
- complete -c switchbot -n '__fish_seen_subcommand_from events' -a 'tail mqtt-tail'
274
-
275
- # quota
276
- complete -c switchbot -n '__fish_seen_subcommand_from quota' -a 'status reset'
277
-
278
- # catalog
279
- complete -c switchbot -n '__fish_seen_subcommand_from catalog' -a 'path show diff refresh'
280
-
281
- # cache
282
- complete -c switchbot -n '__fish_seen_subcommand_from cache' -a 'show clear'
283
-
284
- # history
285
- complete -c switchbot -n '__fish_seen_subcommand_from history' -a 'show replay'
286
-
287
- # plan
288
- complete -c switchbot -n '__fish_seen_subcommand_from plan' -a 'schema validate run'
289
-
290
- # completion
291
- complete -c switchbot -n '__fish_seen_subcommand_from completion' -a 'bash zsh fish powershell'
292
- `;
293
- const POWERSHELL_SCRIPT = `# switchbot PowerShell completion
294
- # Install: switchbot completion powershell | Out-String | Invoke-Expression
295
- # Or add to your profile:
296
- # switchbot completion powershell >> $PROFILE
297
-
298
- Register-ArgumentCompleter -Native -CommandName switchbot -ScriptBlock {
299
- param($wordToComplete, $commandAst, $cursorPosition)
300
-
301
- $tokens = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
302
- $count = $tokens.Count
303
-
304
- $top = 'config','devices','scenes','webhook','completion','mcp','quota','catalog','cache','events','doctor','schema','history','plan','capabilities','help'
305
- $configSub = 'set-token','show','list-profiles'
306
- $devicesSub = 'list','ls','status','command','types','commands','describe','batch','watch','explain','expand','meta'
307
- $scenesSub = 'list','execute'
308
- $webhookSub = 'setup','query','update','delete'
309
- $eventsSub = 'tail','mqtt-tail'
310
- $quotaSub = 'status','reset'
311
- $catalogSub = 'path','show','diff','refresh'
312
- $cacheSub = 'show','clear'
313
- $historySub = 'show','replay'
314
- $planSub = 'schema','validate','run'
315
- $shells = 'bash','zsh','fish','powershell'
316
- $globalOpts = '--json','--format','--fields','--verbose','-v','--dry-run','--timeout','--retry-on-429','--backoff','--no-retry','--no-quota','--cache','--no-cache','--config','--profile','--audit-log','--audit-log-path','--help','-h','--version','-V'
317
-
318
- function _emit($values) {
319
- $values |
320
- Where-Object { $_ -like "$wordToComplete*" } |
321
- ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
322
- }
323
-
324
- if ($count -le 2) { return _emit ($top + $globalOpts) }
325
-
326
- switch ($tokens[1]) {
327
- 'config' { if ($count -eq 3) { return _emit $configSub } }
328
- 'devices' { if ($count -eq 3) { return _emit $devicesSub } }
329
- 'scenes' { if ($count -eq 3) { return _emit $scenesSub } }
330
- 'events' { if ($count -eq 3) { return _emit $eventsSub } }
331
- 'quota' { if ($count -eq 3) { return _emit $quotaSub } }
332
- 'catalog' { if ($count -eq 3) { return _emit $catalogSub } }
333
- 'cache' { if ($count -eq 3) { return _emit $cacheSub } }
334
- 'history' { if ($count -eq 3) { return _emit $historySub } }
335
- 'plan' { if ($count -eq 3) { return _emit $planSub } }
336
- 'webhook' {
337
- if ($count -eq 3) { return _emit $webhookSub }
338
- if ($tokens[2] -eq 'update') { return _emit ('--enable','--disable' + $globalOpts) }
339
- }
340
- 'completion' { if ($count -eq 3) { return _emit $shells } }
341
- }
342
-
343
- return _emit $globalOpts
344
- }
345
- `;
346
- export function registerCompletionCommand(program) {
347
- const completion = program
348
- .command('completion')
349
- .description('Print a shell completion script for bash, zsh, fish, or powershell')
350
- .argument('<shell>', 'Shell to generate completion for: bash | zsh | fish | powershell')
351
- .addHelpText('after', `
352
- The command writes the completion script to stdout. Redirect it to a file or
353
- source it directly:
354
-
355
- bash source <(switchbot completion bash)
356
- # persist: echo 'source <(switchbot completion bash)' >> ~/.bashrc
357
-
358
- zsh source <(switchbot completion zsh)
359
- # persist: echo 'source <(switchbot completion zsh)' >> ~/.zshrc
360
-
361
- fish switchbot completion fish > ~/.config/fish/completions/switchbot.fish
362
-
363
- powershell switchbot completion powershell | Out-String | Invoke-Expression
364
- # persist: switchbot completion powershell >> $PROFILE
365
- `)
366
- .action((shell) => {
367
- switch (shell.toLowerCase()) {
368
- case 'bash':
369
- process.stdout.write(BASH_SCRIPT);
370
- return;
371
- case 'zsh':
372
- process.stdout.write(ZSH_SCRIPT);
373
- return;
374
- case 'fish':
375
- process.stdout.write(FISH_SCRIPT);
376
- return;
377
- case 'powershell':
378
- case 'pwsh':
379
- process.stdout.write(POWERSHELL_SCRIPT);
380
- return;
381
- default:
382
- completion.error(`error: unsupported shell "${shell}" (choose from: bash, zsh, fish, powershell)`, { exitCode: 2, code: 'switchbot.unsupportedShell' });
383
- }
384
- });
385
- }