swarm_cli 2.0.0 → 2.0.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.
- checksums.yaml +4 -4
- data/lib/swarm_cli/cli.rb +0 -1
- data/lib/swarm_cli/interactive_repl.rb +33 -20
- data/lib/swarm_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f57ce5f511e43f8c520bf787d993cdcff34f3152870d496f72b5bbdee962c1a5
|
4
|
+
data.tar.gz: e21157d97dfce0fc71806683b6cb755c0e5ce9901c43c71764aab2b398d23fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8702078d6573711ebe3c08c74571c0ce3d6b1de19810fa324cf6a38122573c7268c906b35e9f3446eb812dbad7d06ce4b61a01e24ff4c2ba5d56244f2b659d0
|
7
|
+
data.tar.gz: 252d1ee2ad3acb39f4302a558ec8633a5eba854522b6924362ecbee4db9f0dfdfe92020a531333d615f1402879b3d2ea8ed9ee4ee140ec668c59a6ad5254f20e
|
data/lib/swarm_cli/cli.rb
CHANGED
@@ -496,6 +496,23 @@ module SwarmCLI
|
|
496
496
|
# Capture COMMANDS for use in lambda
|
497
497
|
commands = COMMANDS
|
498
498
|
|
499
|
+
# Capture file completion logic for use in lambda (since lambda runs in different context)
|
500
|
+
file_completions = lambda do |target|
|
501
|
+
has_at_prefix = target.start_with?("@")
|
502
|
+
query = has_at_prefix ? target[1..] : target
|
503
|
+
|
504
|
+
next Dir.glob("*").sort.first(20) if query.empty?
|
505
|
+
|
506
|
+
# Find files matching query anywhere in path
|
507
|
+
pattern = "**/*#{query}*"
|
508
|
+
found = Dir.glob(pattern, File::FNM_CASEFOLD).reject do |path|
|
509
|
+
path.split("/").any? { |part| part.start_with?(".") }
|
510
|
+
end.sort.first(20)
|
511
|
+
|
512
|
+
# Add @ prefix if needed
|
513
|
+
has_at_prefix ? found.map { |p| "@#{p}" } : found
|
514
|
+
end
|
515
|
+
|
499
516
|
# Custom dialog proc for fuzzy file/command completion
|
500
517
|
fuzzy_proc = lambda do
|
501
518
|
# State: [pre, target, post, matches, pointer, navigating]
|
@@ -503,6 +520,20 @@ module SwarmCLI
|
|
503
520
|
# Check if this is a navigation key press
|
504
521
|
is_nav_key = key&.match?(dialog.name)
|
505
522
|
|
523
|
+
# If we were in navigation mode and user typed a regular key (not Tab), exit nav mode
|
524
|
+
if !context.empty? && context.size >= 6 && context[5] && !is_nav_key
|
525
|
+
context[5] = false # Exit navigation mode
|
526
|
+
end
|
527
|
+
|
528
|
+
# Early check: if user typed and current target has spaces, close dialog
|
529
|
+
unless is_nav_key || context.empty?
|
530
|
+
_, target_check, = retrieve_completion_block
|
531
|
+
if target_check.include?(" ")
|
532
|
+
context.clear
|
533
|
+
return
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
506
537
|
# Detect if we should recalculate matches
|
507
538
|
should_recalculate = if context.empty?
|
508
539
|
true # First time - initialize
|
@@ -529,8 +560,8 @@ module SwarmCLI
|
|
529
560
|
query.empty? || cmd.downcase.include?(query.downcase)
|
530
561
|
end.sort
|
531
562
|
elsif target.start_with?("@") || target.include?("/")
|
532
|
-
# File path completions -
|
533
|
-
|
563
|
+
# File path completions - use captured lambda
|
564
|
+
file_completions.call(target)
|
534
565
|
end
|
535
566
|
|
536
567
|
return if matches.nil? || matches.empty?
|
@@ -605,23 +636,5 @@ module SwarmCLI
|
|
605
636
|
# Register the custom fuzzy dialog
|
606
637
|
Reline.add_dialog_proc(:fuzzy_complete, fuzzy_proc, [])
|
607
638
|
end
|
608
|
-
|
609
|
-
# Get file path completions with fuzzy matching
|
610
|
-
# Extracted to reduce block nesting in the dialog lambda
|
611
|
-
def get_file_completions(target)
|
612
|
-
has_at_prefix = target.start_with?("@")
|
613
|
-
query = has_at_prefix ? target[1..] : target
|
614
|
-
|
615
|
-
return Dir.glob("*").sort.first(20) if query.empty?
|
616
|
-
|
617
|
-
# Find files matching query anywhere in path
|
618
|
-
pattern = "**/*#{query}*"
|
619
|
-
found = Dir.glob(pattern, File::FNM_CASEFOLD).reject do |path|
|
620
|
-
path.split("/").any? { |part| part.start_with?(".") }
|
621
|
-
end.sort.first(20)
|
622
|
-
|
623
|
-
# Add @ prefix if needed
|
624
|
-
has_at_prefix ? found.map { |p| "@#{p}" } : found
|
625
|
-
end
|
626
639
|
end
|
627
640
|
end
|
data/lib/swarm_cli/version.rb
CHANGED