tabry 0.2.2 → 0.2.3
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/tabry/config_builder/arg_or_flag_builder.rb +5 -0
- data/lib/tabry/config_builder/top_level_builder.rb +2 -0
- data/lib/tabry/machine.rb +1 -1
- data/lib/tabry/models/method_option.rb +14 -0
- data/lib/tabry/models/option.rb +5 -5
- data/lib/tabry/replty/base.rb +23 -0
- data/lib/tabry/replty/builder.rb +100 -0
- data/lib/tabry/shell_tokenizer.rb +50 -0
- data/lib/tabry/shells/bash/wrapper.rb +2 -2
- data/sh/fish/tabry_fish.fish +7 -4
- data/spec/fixtures/config_builder/underscoresdashes.yml +1 -1
- data/spec/fixtures/vehicles-expectations.json +351 -0
- data/spec/tabry/machine_spec.rb +5 -82
- data/spec/tabry/shell_tokenizer_spec.rb +34 -0
- data/tabry.gemspec +1 -1
- data/treesitter/corpus/opts.txt +2 -0
- data/treesitter/grammar.js +7 -0
- data/treesitter/src/grammar.json +21 -0
- data/treesitter/src/node-types.json +23 -0
- data/treesitter/src/parser.c +959 -893
- data/treesitter/tabry-compile.js +6 -0
- metadata +9 -5
- data/lib/tabry/shell_splitter.rb +0 -34
- data/spec/tabry/shell_splitter_spec.rb +0 -22
data/treesitter/tabry-compile.js
CHANGED
@@ -317,6 +317,12 @@ const handlers = {
|
|
317
317
|
createOpts(state, {type: 'shell', value: textFromString(value)});
|
318
318
|
},
|
319
319
|
|
320
|
+
handleOptsMethodStatement(state, node) {
|
321
|
+
checkContext(state, node, ['arg', 'flag', 'option_include']);
|
322
|
+
const {value} = pick(node, {value: 'string'});
|
323
|
+
createOpts(state, {type: 'method', value: textFromString(value)});
|
324
|
+
},
|
325
|
+
|
320
326
|
handleOptsFileStatement(state, node) {
|
321
327
|
checkContext(state, node, ['arg', 'flag', 'option_include']);
|
322
328
|
createOpts(state, {type: 'file'});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Battaglia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/tabry/models/include_flag.rb
|
133
133
|
- lib/tabry/models/include_option.rb
|
134
134
|
- lib/tabry/models/include_sub.rb
|
135
|
+
- lib/tabry/models/method_option.rb
|
135
136
|
- lib/tabry/models/option.rb
|
136
137
|
- lib/tabry/models/option_base.rb
|
137
138
|
- lib/tabry/models/option_includes.rb
|
@@ -140,9 +141,11 @@ files:
|
|
140
141
|
- lib/tabry/models/sub.rb
|
141
142
|
- lib/tabry/models/subs_list.rb
|
142
143
|
- lib/tabry/options_finder.rb
|
144
|
+
- lib/tabry/replty/base.rb
|
145
|
+
- lib/tabry/replty/builder.rb
|
143
146
|
- lib/tabry/result.rb
|
144
147
|
- lib/tabry/runner.rb
|
145
|
-
- lib/tabry/
|
148
|
+
- lib/tabry/shell_tokenizer.rb
|
146
149
|
- lib/tabry/shells/bash.rb
|
147
150
|
- lib/tabry/shells/bash/wrapper.rb
|
148
151
|
- lib/tabry/state.rb
|
@@ -173,6 +176,7 @@ files:
|
|
173
176
|
- spec/fixtures/config_builder/underscoresdashes.rb
|
174
177
|
- spec/fixtures/config_builder/underscoresdashes.tabry
|
175
178
|
- spec/fixtures/config_builder/underscoresdashes.yml
|
179
|
+
- spec/fixtures/vehicles-expectations.json
|
176
180
|
- spec/fixtures/vehicles.tabry
|
177
181
|
- spec/fixtures/vehicles.yaml
|
178
182
|
- spec/spec_helper.rb
|
@@ -194,7 +198,7 @@ files:
|
|
194
198
|
- spec/tabry/options_finder_spec.rb
|
195
199
|
- spec/tabry/result_spec.rb
|
196
200
|
- spec/tabry/runner_spec.rb
|
197
|
-
- spec/tabry/
|
201
|
+
- spec/tabry/shell_tokenizer_spec.rb
|
198
202
|
- spec/tabry/shells/bash_spec.rb
|
199
203
|
- spec/tabry/usage_generator_spec.rb
|
200
204
|
- tabry.gemspec
|
@@ -253,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
257
|
- !ruby/object:Gem::Version
|
254
258
|
version: '0'
|
255
259
|
requirements: []
|
256
|
-
rubygems_version: 3.
|
260
|
+
rubygems_version: 3.3.26
|
257
261
|
signing_key:
|
258
262
|
specification_version: 4
|
259
263
|
summary: Tab completion and CLIs extraordinaire
|
data/lib/tabry/shell_splitter.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Use Shellwords.split() to split a command line + comp point (index of the
|
4
|
-
# cursor in the command line) into the args up to the current token plus
|
5
|
-
# current token
|
6
|
-
module Tabry
|
7
|
-
module ShellSplitter
|
8
|
-
module_function
|
9
|
-
|
10
|
-
COMP_POINT_SENTINEL = "\uFFFF"
|
11
|
-
|
12
|
-
def split(cmd_line, comp_point)
|
13
|
-
# Returns [cmd_name, args, last_arg]
|
14
|
-
# cmd_name is the basename of the command run
|
15
|
-
#
|
16
|
-
# TODO: in weird scenarios this acts weird: namely, special shell operators like <(ls), $$((1 + 1))
|
17
|
-
# Also it crashed on unbalanced quotes, like: foo "bar<TAB>
|
18
|
-
# however, this will handle the common scenarios of escaping with quotes, single quotes, and backslashes
|
19
|
-
# Split up args and put the argument that comp_point is in in the `last_arg` variable.
|
20
|
-
# Just cutting off everything after comp_point might have worked, although
|
21
|
-
# maybe we wanted the whole arg? Not sure this is the best.
|
22
|
-
cmd_line = cmd_line.dup
|
23
|
-
cmd_line[comp_point.to_i...comp_point.to_i] = COMP_POINT_SENTINEL
|
24
|
-
cmd, *all_args = Shellwords.split(cmd_line)
|
25
|
-
last_arg_index = all_args.index { |arg| arg.include?(COMP_POINT_SENTINEL) }
|
26
|
-
args = all_args[0..last_arg_index]
|
27
|
-
last_arg = args.pop.gsub! COMP_POINT_SENTINEL, ""
|
28
|
-
|
29
|
-
cmd_name = cmd.gsub(%r{.*/}, "")
|
30
|
-
|
31
|
-
[cmd_name, args, last_arg]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../../lib/tabry/shell_splitter"
|
4
|
-
|
5
|
-
describe Tabry::ShellSplitter do
|
6
|
-
describe ".split" do
|
7
|
-
it "returns the command basename, argument, and last argument" do
|
8
|
-
str = "foo/bar abc def ghi"
|
9
|
-
expect(described_class.split(str, 13)).to eq(["bar", ["abc"], "def"])
|
10
|
-
end
|
11
|
-
|
12
|
-
it "handles quotes and backslashes like a shell" do
|
13
|
-
expect(described_class.split('"/foo bar/waz" a\'b \'c\\ d "ef g" "hi jk" lmn', 38)).to eq(
|
14
|
-
[
|
15
|
-
"waz",
|
16
|
-
["ab c d", "ef g"],
|
17
|
-
"hi jk"
|
18
|
-
]
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|