dkit 0.3.3 → 0.4.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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/bin/dkit +50 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b4a5d2779f046a28fd08f82a5564621b5856617507e5e9a7891981818318ff
4
- data.tar.gz: e5f0e728e94bc3b45a80f7834dfc3cdc76458689eda7b5000e6851d1e6ed31a8
3
+ metadata.gz: 50d35a0b2d2d8d179be81ce6360eccc29cacd941125ce01dc7202954a7499ab1
4
+ data.tar.gz: 727ca198989f81815d6aa2fecb8a2096ababe1402de1f2e73e0cdc07938753dc
5
5
  SHA512:
6
- metadata.gz: 7236faaaad611849ad0446036ab189bfd16fd54f39f7f032569658859a21c64236fc103b9516ca90369ae454ed5616f681ee1ce912a2729e5a2d321d7d86f1de
7
- data.tar.gz: b0d487ab8e2df9f522bc7d6a9fd58a697492020f1dc8bd71ec8946e25f152b3a686d1489b7986e42fd128fa5a7cddb2f2f0a69550f2ce30089344e3839ddfb08
6
+ metadata.gz: 24a65808288983e07fe1897600f467d763518c09954480c6b0dd753e2f310a055c8928e1cd7cf3933c46945ac6a6f2b87eecdb66d754f083e24c20d82153e595
7
+ data.tar.gz: 6e604b67d3bafed4b1c90794fd5bf9309a807dbdcd5a0d72f7641f0b5faeb20b7da3a9db2206e983461c43d94204195269c4abfd24ed9b660ec4a603ab5e2e9b
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.0] - 2026-04-13
9
+
10
+ ### Added
11
+ - Glob/wildcard patterns in intercept file: `bin/*` intercepts all executables under `bin/` (e.g. `bin/rails`, `bin/rspec`)
12
+ - New zsh helpers `_dkit_expand_glob` and `_dkit_refresh_globs` for dynamic function creation from glob patterns
13
+ - `precmd` hook automatically picks up new executables and cleans up deleted ones between prompts
14
+ - Help text documents glob usage with quoting example
15
+
16
+ ### Notes
17
+ - Glob patterns must be quoted to prevent shell expansion: `dkit intercept add 'bin/*'`
18
+ - Only executable files are matched (non-executable files like READMEs are skipped)
19
+ - Requires `exec zsh` after gem update to reload the shell hook
20
+
8
21
  ## [0.3.3] - 2026-04-13
9
22
 
10
23
  ### Changed
data/bin/dkit CHANGED
@@ -16,7 +16,7 @@ require 'pathname'
16
16
  require 'shellwords'
17
17
  require 'fileutils'
18
18
 
19
- VERSION = "0.3.3"
19
+ VERSION = "0.4.0"
20
20
  DC_CONFIG = ".devcontainer/devcontainer.json"
21
21
  DC_INTERCEPT = ".devcontainer/dkit-intercept"
22
22
 
@@ -228,6 +228,8 @@ def cmd_hook
228
228
 
229
229
  _DKIT_ROOT=""
230
230
  _DKIT_ACTIVE_CMDS=()
231
+ _DKIT_GLOB_PATTERNS=()
232
+ _DKIT_GLOB_CMDS=()
231
233
 
232
234
  _dkit_reset() {
233
235
  local cmd
@@ -235,6 +237,8 @@ def cmd_hook
235
237
  unfunction "$cmd" 2>/dev/null
236
238
  done
237
239
  _DKIT_ACTIVE_CMDS=()
240
+ _DKIT_GLOB_PATTERNS=()
241
+ _DKIT_GLOB_CMDS=()
238
242
  }
239
243
 
240
244
  _dkit_verbose_fallback() {
@@ -244,6 +248,43 @@ def cmd_hook
244
248
  printf '\033[31m[dkit] %s → host (fallback)\033[0m\n' "$1" >&2
245
249
  }
246
250
 
251
+ _dkit_expand_glob() {
252
+ local root="$1" pattern="$2"
253
+ local full_pattern="$root/$pattern"
254
+ local matches=( ${~full_pattern}(N*) )
255
+ local m rel
256
+ for m in "${matches[@]}"; do
257
+ rel="${m#$root/}"
258
+ (( ${_DKIT_ACTIVE_CMDS[(Ie)$rel]} )) && continue
259
+ eval "function ${rel}() {
260
+ if dkit status --quiet 2>/dev/null; then
261
+ dkit run ${rel} \"\$@\"
262
+ else
263
+ _dkit_verbose_fallback \"${rel}\"
264
+ command ${rel} \"\$@\"
265
+ fi
266
+ }"
267
+ _DKIT_ACTIVE_CMDS+=("${rel}")
268
+ _DKIT_GLOB_CMDS+=("${rel}")
269
+ done
270
+ }
271
+
272
+ _dkit_refresh_globs() {
273
+ [[ -z "$_DKIT_ROOT" || ${#_DKIT_GLOB_PATTERNS[@]} -eq 0 ]] && return
274
+ local cmd
275
+ for cmd in "${_DKIT_GLOB_CMDS[@]}"; do
276
+ if [[ ! -e "$_DKIT_ROOT/$cmd" ]]; then
277
+ unfunction "$cmd" 2>/dev/null
278
+ _DKIT_ACTIVE_CMDS=("${(@)_DKIT_ACTIVE_CMDS:#$cmd}")
279
+ fi
280
+ done
281
+ _DKIT_GLOB_CMDS=()
282
+ local pat
283
+ for pat in "${_DKIT_GLOB_PATTERNS[@]}"; do
284
+ _dkit_expand_glob "$_DKIT_ROOT" "$pat"
285
+ done
286
+ }
287
+
247
288
  _dkit_load() {
248
289
  local root="$1"
249
290
  local intercept="$root/.devcontainer/dkit-intercept"
@@ -255,6 +296,12 @@ def cmd_hook
255
296
  cmd="${cmd## }"
256
297
  cmd="${cmd%% }"
257
298
  [[ -z "$cmd" ]] && continue
299
+ # Glob pattern: expand matching executables
300
+ if [[ "$cmd" == *[\*\?\[]* ]]; then
301
+ _DKIT_GLOB_PATTERNS+=("${cmd}")
302
+ _dkit_expand_glob "$root" "$cmd"
303
+ continue
304
+ fi
258
305
  eval "function ${cmd}() {
259
306
  if dkit status --quiet 2>/dev/null; then
260
307
  dkit run ${cmd} \"\$@\"
@@ -301,6 +348,7 @@ def cmd_hook
301
348
 
302
349
  autoload -U add-zsh-hook
303
350
  add-zsh-hook chpwd _dkit_chpwd
351
+ add-zsh-hook precmd _dkit_refresh_globs
304
352
  _dkit_chpwd
305
353
  ZSH
306
354
  end
@@ -393,6 +441,7 @@ def cmd_help
393
441
  dkit init Create .devcontainer/dkit-intercept with auto-detected defaults
394
442
  dkit intercept list List intercepted commands for current project
395
443
  dkit intercept add <cmd> Add command to current project's intercept list
444
+ dkit intercept add 'bin/*' Add glob pattern (quote to prevent shell expansion)
396
445
  dkit intercept remove <cmd> Remove command from current project's intercept list
397
446
 
398
447
  Verbose routing messages (on by default):
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Augusto Stroligo