tabry 0.2.2 → 0.2.4
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/bin/tabry-fish +9 -0
- data/bin/tabry-generate-fish-complete +31 -0
- data/lib/tabry/cli/all_in_one.rb +27 -6
- data/lib/tabry/config_builder/arg_or_flag_builder.rb +5 -0
- data/lib/tabry/config_builder/top_level_builder.rb +3 -0
- data/lib/tabry/machine.rb +1 -1
- data/lib/tabry/models/const_option.rb +1 -1
- data/lib/tabry/models/flags_list.rb +6 -2
- data/lib/tabry/models/include_option.rb +2 -2
- data/lib/tabry/models/method_option.rb +14 -0
- data/lib/tabry/models/option.rb +5 -5
- data/lib/tabry/models/options_list.rb +2 -2
- data/lib/tabry/models/shell_option.rb +1 -1
- data/lib/tabry/models/subs_list.rb +13 -2
- data/lib/tabry/options_finder.rb +13 -8
- data/lib/tabry/replty/base.rb +23 -0
- data/lib/tabry/replty/builder.rb +100 -0
- data/lib/tabry/runner.rb +2 -2
- data/lib/tabry/shell_tokenizer.rb +50 -0
- data/lib/tabry/shells/bash/wrapper.rb +2 -2
- data/lib/tabry/shells/fish/wrapper.rb +51 -0
- data/lib/tabry/shells/fish.rb +82 -0
- data/lib/tabry/version.rb +3 -0
- data/sh/fish/README.md +2 -1
- data/sh/fish/tabry_fish.fish +17 -11
- data/spec/fixtures/config_builder/underscoresdashes.yml +1 -1
- data/spec/fixtures/vehicles-expectations.json +351 -0
- data/spec/tabry/cli/all_in_one_spec.rb +12 -0
- data/spec/tabry/machine_spec.rb +5 -82
- data/spec/tabry/shell_tokenizer_spec.rb +34 -0
- data/tabry.gemspec +2 -4
- 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 +16 -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.4
|
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-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -84,7 +84,9 @@ description:
|
|
84
84
|
email: battaglia.evan@gmail.com
|
85
85
|
executables:
|
86
86
|
- tabry-bash
|
87
|
+
- tabry-fish
|
87
88
|
- tabry-generate-bash-complete
|
89
|
+
- tabry-generate-fish-complete
|
88
90
|
- tabry-help
|
89
91
|
- tabry-test-options
|
90
92
|
- tabry-test-parse
|
@@ -92,7 +94,9 @@ extensions: []
|
|
92
94
|
extra_rdoc_files: []
|
93
95
|
files:
|
94
96
|
- bin/tabry-bash
|
97
|
+
- bin/tabry-fish
|
95
98
|
- bin/tabry-generate-bash-complete
|
99
|
+
- bin/tabry-generate-fish-complete
|
96
100
|
- bin/tabry-help
|
97
101
|
- bin/tabry-test-options
|
98
102
|
- bin/tabry-test-parse
|
@@ -132,6 +136,7 @@ files:
|
|
132
136
|
- lib/tabry/models/include_flag.rb
|
133
137
|
- lib/tabry/models/include_option.rb
|
134
138
|
- lib/tabry/models/include_sub.rb
|
139
|
+
- lib/tabry/models/method_option.rb
|
135
140
|
- lib/tabry/models/option.rb
|
136
141
|
- lib/tabry/models/option_base.rb
|
137
142
|
- lib/tabry/models/option_includes.rb
|
@@ -140,14 +145,19 @@ files:
|
|
140
145
|
- lib/tabry/models/sub.rb
|
141
146
|
- lib/tabry/models/subs_list.rb
|
142
147
|
- lib/tabry/options_finder.rb
|
148
|
+
- lib/tabry/replty/base.rb
|
149
|
+
- lib/tabry/replty/builder.rb
|
143
150
|
- lib/tabry/result.rb
|
144
151
|
- lib/tabry/runner.rb
|
145
|
-
- lib/tabry/
|
152
|
+
- lib/tabry/shell_tokenizer.rb
|
146
153
|
- lib/tabry/shells/bash.rb
|
147
154
|
- lib/tabry/shells/bash/wrapper.rb
|
155
|
+
- lib/tabry/shells/fish.rb
|
156
|
+
- lib/tabry/shells/fish/wrapper.rb
|
148
157
|
- lib/tabry/state.rb
|
149
158
|
- lib/tabry/usage_generator.rb
|
150
159
|
- lib/tabry/util.rb
|
160
|
+
- lib/tabry/version.rb
|
151
161
|
- sh/bash/README.md
|
152
162
|
- sh/bash/tabry_bash.sh
|
153
163
|
- sh/bash/tabry_bash_core.sh
|
@@ -173,6 +183,7 @@ files:
|
|
173
183
|
- spec/fixtures/config_builder/underscoresdashes.rb
|
174
184
|
- spec/fixtures/config_builder/underscoresdashes.tabry
|
175
185
|
- spec/fixtures/config_builder/underscoresdashes.yml
|
186
|
+
- spec/fixtures/vehicles-expectations.json
|
176
187
|
- spec/fixtures/vehicles.tabry
|
177
188
|
- spec/fixtures/vehicles.yaml
|
178
189
|
- spec/spec_helper.rb
|
@@ -194,7 +205,7 @@ files:
|
|
194
205
|
- spec/tabry/options_finder_spec.rb
|
195
206
|
- spec/tabry/result_spec.rb
|
196
207
|
- spec/tabry/runner_spec.rb
|
197
|
-
- spec/tabry/
|
208
|
+
- spec/tabry/shell_tokenizer_spec.rb
|
198
209
|
- spec/tabry/shells/bash_spec.rb
|
199
210
|
- spec/tabry/usage_generator_spec.rb
|
200
211
|
- tabry.gemspec
|
@@ -253,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
264
|
- !ruby/object:Gem::Version
|
254
265
|
version: '0'
|
255
266
|
requirements: []
|
256
|
-
rubygems_version: 3.
|
267
|
+
rubygems_version: 3.3.26
|
257
268
|
signing_key:
|
258
269
|
specification_version: 4
|
259
270
|
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
|