@garyr/pt-cli 1.3.0 → 1.3.1

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.
@@ -67,9 +67,28 @@ _pt_completions() {
67
67
  if [[ "$cur" == -* ]]; then
68
68
  COMPREPLY=( $(compgen -W "-f --file --skip-post-config --dry-run -y --yes --vars --collision --json -h --help" -- "$cur") )
69
69
  elif [[ $cword -ge 2 ]]; then
70
+ # Try template name completion first
70
71
  local templates
71
72
  templates=$(pt completion --templates 2>/dev/null)
72
- COMPREPLY=( $(compgen -W "$templates" -- "$cur") )
73
+ local template_matches
74
+ template_matches=$(compgen -W "$templates" -- "$cur")
75
+
76
+ # If we're at a position where destination could be (cword >= 2 for first arg after init,
77
+ # or cword >= 3 with templates already specified),
78
+ # also try directory completion. This handles cases like "pt init Base SPA PARK<TAB>"
79
+ local dir_matches
80
+ if [[ $cword -ge 2 ]]; then
81
+ dir_matches=$(compgen -d -- "$cur")
82
+ fi
83
+
84
+ # Combine matches - template matches first, then directory matches
85
+ COMPREPLY=()
86
+ if [[ -n "$template_matches" ]]; then
87
+ COMPREPLY=( $template_matches )
88
+ fi
89
+ if [[ -n "$dir_matches" ]]; then
90
+ COMPREPLY+=( $dir_matches )
91
+ fi
73
92
  fi
74
93
  ;;
75
94
  config)
@@ -192,16 +211,16 @@ _pt() {
192
211
  '2:sourcePath:_files -/'
193
212
  ;;
194
213
  init)
195
- _arguments \\
196
- '(-f --file)'{-f,--file}'[Initialize directly from a JSON template file]:file:_files' \\
197
- '--skip-post-config[Skip running post-config tasks]' \\
198
- '--dry-run[Show what would be created without making changes]' \\
199
- '(-y --yes)'{-y,--yes}'[Automatically answer yes to prompts]' \\
200
- '--vars=[Comma-separated key=value variables]:variables:' \\
201
- '--collision=[File collision resolution strategy]:mode:(overwrite newest)' \\
202
- '--json[Output result as JSON]' \\
203
- '(-h --help)'{-h,--help}'[display help for command]' \\
204
- '*:templates:_pt_templates'
214
+ _arguments \
215
+ '(-f --file)'{-f,--file}'[Initialize directly from a JSON template file]:file:_files' \
216
+ '--skip-post-config[Skip running post-config tasks]' \
217
+ '--dry-run[Show what would be created without making changes]' \
218
+ '(-y --yes)'{-y,--yes}'[Automatically answer yes to prompts]' \
219
+ '--vars=[Comma-separated key=value variables]:variables:' \
220
+ '--collision=[File collision resolution strategy]:mode:(overwrite newest)' \
221
+ '--json[Output result as JSON]' \
222
+ '(-h --help)'{-h,--help}'[display help for command]' \
223
+ '*: :(_pt_templates _directories)'
205
224
  ;;
206
225
  config)
207
226
  _arguments \\
@@ -322,6 +341,7 @@ complete -c pt -n '__fish_pt_using_command update' -l no-diff -d 'Disable additi
322
341
 
323
342
  # init
324
343
  complete -c pt -n '__fish_pt_using_command init' -a '(__fish_pt_templates)' -d 'Template name'
344
+ complete -c pt -n '__fish_pt_using_command init' -F -d 'Target directory' --wraps=pt --condition=__fish_pt_init_dir
325
345
  complete -c pt -n '__fish_pt_using_command init' -s f -l file -d 'Initialize directly from a JSON template file without adding it to local config'
326
346
  complete -c pt -n '__fish_pt_using_command init' -l skip-post-config -d 'Skip running post-config tasks'
327
347
  complete -c pt -n '__fish_pt_using_command init' -l dry-run -d 'Show what would be created without making changes'
@@ -330,6 +350,20 @@ complete -c pt -n '__fish_pt_using_command init' -l vars -d 'Comma-separated key
330
350
  complete -c pt -n '__fish_pt_using_command init' -l collision -a 'overwrite newest' -d 'File collision resolution strategy'
331
351
  complete -c pt -n '__fish_pt_using_command init' -l json -d 'Output result as JSON'
332
352
 
353
+ # Helper function for init directory completion (only when last positional arg looks like a path)
354
+ function __fish_pt_init_dir
355
+ set -l cmd (commandline -opc)
356
+ # Count non-flag positional arguments after 'init'
357
+ set -l args (string match -r '(^[^ ]+ )?init( .+)?' <<< "$cmd")
358
+ # Simple approach: if the current token contains / or starts with ~ or ., complete as directory
359
+ set -l cur (commandline -ct)
360
+ if string match -q '*/' "$cur"; or string match -q '~*' "$cur"; or string match -q '.*' "$cur"
361
+ return 0
362
+ else
363
+ return 1
364
+ end
365
+ end
366
+
333
367
  # config
334
368
  complete -c pt -n '__fish_pt_using_command config' -a '(__fish_pt_templates)' -d 'Template name'
335
369
  complete -c pt -n '__fish_pt_using_command config' -l json -d 'Output config or specific template as JSON'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garyr/pt-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Project Template CLI - Learn structures and initialize projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -68,9 +68,28 @@ _pt_completions() {
68
68
  if [[ "$cur" == -* ]]; then
69
69
  COMPREPLY=( $(compgen -W "-f --file --skip-post-config --dry-run -y --yes --vars --collision --json -h --help" -- "$cur") )
70
70
  elif [[ $cword -ge 2 ]]; then
71
+ # Try template name completion first
71
72
  local templates
72
73
  templates=$(pt completion --templates 2>/dev/null)
73
- COMPREPLY=( $(compgen -W "$templates" -- "$cur") )
74
+ local template_matches
75
+ template_matches=$(compgen -W "$templates" -- "$cur")
76
+
77
+ # If we're at a position where destination could be (cword >= 2 for first arg after init,
78
+ # or cword >= 3 with templates already specified),
79
+ # also try directory completion. This handles cases like "pt init Base SPA PARK<TAB>"
80
+ local dir_matches
81
+ if [[ $cword -ge 2 ]]; then
82
+ dir_matches=$(compgen -d -- "$cur")
83
+ fi
84
+
85
+ # Combine matches - template matches first, then directory matches
86
+ COMPREPLY=()
87
+ if [[ -n "$template_matches" ]]; then
88
+ COMPREPLY=( $template_matches )
89
+ fi
90
+ if [[ -n "$dir_matches" ]]; then
91
+ COMPREPLY+=( $dir_matches )
92
+ fi
74
93
  fi
75
94
  ;;
76
95
  config)
@@ -194,16 +213,16 @@ _pt() {
194
213
  '2:sourcePath:_files -/'
195
214
  ;;
196
215
  init)
197
- _arguments \\
198
- '(-f --file)'{-f,--file}'[Initialize directly from a JSON template file]:file:_files' \\
199
- '--skip-post-config[Skip running post-config tasks]' \\
200
- '--dry-run[Show what would be created without making changes]' \\
201
- '(-y --yes)'{-y,--yes}'[Automatically answer yes to prompts]' \\
202
- '--vars=[Comma-separated key=value variables]:variables:' \\
203
- '--collision=[File collision resolution strategy]:mode:(overwrite newest)' \\
204
- '--json[Output result as JSON]' \\
205
- '(-h --help)'{-h,--help}'[display help for command]' \\
206
- '*:templates:_pt_templates'
216
+ _arguments \
217
+ '(-f --file)'{-f,--file}'[Initialize directly from a JSON template file]:file:_files' \
218
+ '--skip-post-config[Skip running post-config tasks]' \
219
+ '--dry-run[Show what would be created without making changes]' \
220
+ '(-y --yes)'{-y,--yes}'[Automatically answer yes to prompts]' \
221
+ '--vars=[Comma-separated key=value variables]:variables:' \
222
+ '--collision=[File collision resolution strategy]:mode:(overwrite newest)' \
223
+ '--json[Output result as JSON]' \
224
+ '(-h --help)'{-h,--help}'[display help for command]' \
225
+ '*: :(_pt_templates _directories)'
207
226
  ;;
208
227
  config)
209
228
  _arguments \\
@@ -325,6 +344,7 @@ complete -c pt -n '__fish_pt_using_command update' -l no-diff -d 'Disable additi
325
344
 
326
345
  # init
327
346
  complete -c pt -n '__fish_pt_using_command init' -a '(__fish_pt_templates)' -d 'Template name'
347
+ complete -c pt -n '__fish_pt_using_command init' -F -d 'Target directory' --wraps=pt --condition=__fish_pt_init_dir
328
348
  complete -c pt -n '__fish_pt_using_command init' -s f -l file -d 'Initialize directly from a JSON template file without adding it to local config'
329
349
  complete -c pt -n '__fish_pt_using_command init' -l skip-post-config -d 'Skip running post-config tasks'
330
350
  complete -c pt -n '__fish_pt_using_command init' -l dry-run -d 'Show what would be created without making changes'
@@ -333,6 +353,20 @@ complete -c pt -n '__fish_pt_using_command init' -l vars -d 'Comma-separated key
333
353
  complete -c pt -n '__fish_pt_using_command init' -l collision -a 'overwrite newest' -d 'File collision resolution strategy'
334
354
  complete -c pt -n '__fish_pt_using_command init' -l json -d 'Output result as JSON'
335
355
 
356
+ # Helper function for init directory completion (only when last positional arg looks like a path)
357
+ function __fish_pt_init_dir
358
+ set -l cmd (commandline -opc)
359
+ # Count non-flag positional arguments after 'init'
360
+ set -l args (string match -r '(^[^ ]+ )?init( .+)?' <<< "$cmd")
361
+ # Simple approach: if the current token contains / or starts with ~ or ., complete as directory
362
+ set -l cur (commandline -ct)
363
+ if string match -q '*/' "$cur"; or string match -q '~*' "$cur"; or string match -q '.*' "$cur"
364
+ return 0
365
+ else
366
+ return 1
367
+ end
368
+ end
369
+
336
370
  # config
337
371
  complete -c pt -n '__fish_pt_using_command config' -a '(__fish_pt_templates)' -d 'Template name'
338
372
  complete -c pt -n '__fish_pt_using_command config' -l json -d 'Output config or specific template as JSON'