samovar 2.5.0 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c0de84734b05646d8e1effd9c06339148112dc6202636d436f2909c6bb5835
4
- data.tar.gz: 5d2a79b6375044119235462e71af0b9ca63f7c9ab272cd118f125a4967bae3bf
3
+ metadata.gz: b8bdded07aeaa6cc737bf9c08155dcd2c954521f8cd066dbeb6786c5ba325b02
4
+ data.tar.gz: a469ff20b8426b570700cb6cc2daaba39e689aa12f8df58ed9701a516f2be4f0
5
5
  SHA512:
6
- metadata.gz: '09729f11890c05e4f15aa07b9af5202f718c5769f1e794fb9a90b8b843b230c98215cfb96d260923d7fad50cf6bb734f71c24f8f871e38e30c39cc9fc8a2242a'
7
- data.tar.gz: a8927f7dd61c3423ea892049dcc4d776811601fd6932a3a0ed1834d6e0751deb3c04bffeea434884a2ea3649640e12d3a02048413b3f5392fb3bc94c1ab68932
6
+ metadata.gz: e48219e31bda0451b3c59752077f470e55794621f2f1b011d60b73caae7bf0695ba7c4a90c7f956e02ff066e5ca12102e571fcc543632da64d1edaa1a69b1a44
7
+ data.tar.gz: 230b563dd99c38945c8ea041ed399eaea8f245bf6476295ec097cebdd818c5f1cd66473603a37f51c741a0bdb3a991f94595e145a0714ed7f3715e92b5c131b2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -16,10 +16,13 @@ module Samovar
16
16
  # @parameter environment [Hash] The environment for completion callbacks.
17
17
  # @returns [Context] The completion context.
18
18
  def self.for(command_class, arguments, environment: ENV)
19
+ arguments = arguments.dup
20
+ current = arguments.pop || ""
21
+
19
22
  return self.new(
20
23
  command_class.table.merged,
21
24
  arguments,
22
- arguments.last || "",
25
+ current,
23
26
  environment: environment,
24
27
  )
25
28
  end
@@ -27,7 +30,7 @@ module Samovar
27
30
  # Initialize a new completion context.
28
31
  #
29
32
  # @parameter table [Table] The command table to complete.
30
- # @parameter arguments [Array(String)] The truncated command-line arguments.
33
+ # @parameter arguments [Array(String)] The completed words before the current token.
31
34
  # @parameter current [String] The token being completed.
32
35
  # @parameter row [Object | Nil] The parser row whose value is being completed.
33
36
  # @parameter environment [Hash] The environment for completion callbacks.
@@ -42,7 +45,7 @@ module Samovar
42
45
  # @attribute [Table] The command table to complete.
43
46
  attr :table
44
47
 
45
- # @attribute [Array(String)] The truncated command-line arguments.
48
+ # @attribute [Array(String)] The completed words before the current token.
46
49
  attr :arguments
47
50
 
48
51
  # @attribute [String] The token being completed.
@@ -68,18 +71,11 @@ module Samovar
68
71
  )
69
72
  end
70
73
 
71
- # The completed words before the current token.
72
- #
73
- # @returns [Array(String)] The arguments before the token being completed.
74
- def words
75
- @arguments.take(@arguments.size - 1)
76
- end
77
-
78
74
  # Complete the current command class.
79
75
  #
80
76
  # @returns [Result] The completion result.
81
77
  def complete
82
- complete_rows(@table, words)
78
+ complete_rows(@table, @arguments.dup)
83
79
  end
84
80
 
85
81
  # Complete the given command class with completed words.
data/lib/samovar/split.rb CHANGED
@@ -111,7 +111,7 @@ module Samovar
111
111
  input.first,
112
112
  description: "Delegate completion",
113
113
  type: :delegate,
114
- index: context.words.index(@marker) + 1,
114
+ index: context.arguments.index(@marker) + 1,
115
115
  ),
116
116
  ])
117
117
  end
@@ -6,5 +6,5 @@
6
6
 
7
7
  # @namespace
8
8
  module Samovar
9
- VERSION = "2.5.0"
9
+ VERSION = "2.5.1"
10
10
  end
data/readme.md CHANGED
@@ -24,6 +24,10 @@ Please see the [project documentation](https://ioquatix.github.io/samovar/) for
24
24
 
25
25
  Please see the [project releases](https://ioquatix.github.io/samovar/releases/index) for all releases.
26
26
 
27
+ ### v2.5.1
28
+
29
+ - Fix completion of empty arguments.
30
+
27
31
  ### v2.5.0
28
32
 
29
33
  - Introduce `Command#complete` which provides a hook for command completion logic, allowing developers to implement custom tab-completion behavior for their commands.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v2.5.1
4
+
5
+ - Fix completion of empty arguments.
6
+
3
7
  ## v2.5.0
4
8
 
5
9
  - Introduce `Command#complete` which provides a hook for command completion logic, allowing developers to implement custom tab-completion behavior for their commands.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samovar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file