tabry 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tabry/cli/flag_proxy.rb +4 -0
- data/lib/tabry/models/dir_option.rb +2 -2
- data/lib/tabry/models/file_option.rb +2 -2
- data/lib/tabry/models/flags_list.rb +1 -1
- data/lib/tabry/options_finder.rb +1 -1
- data/lib/tabry/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/tabry/config_builder_spec.rb +4 -0
- data/spec/tabry/models/const_option_spec.rb +4 -4
- data/spec/tabry/models/dir_option_spec.rb +1 -1
- data/spec/tabry/models/file_option_spec.rb +1 -1
- data/spec/tabry/models/options_list_spec.rb +2 -2
- data/spec/tabry/models/shell_option_spec.rb +4 -4
- data/spec/tabry/options_finder_spec.rb +3 -3
- data/spec/tabry/replty/builder_spec.rb +39 -0
- data/spec/tabry/runner_spec.rb +1 -1
- data/spec/tabry/shell_tokenizer_spec.rb +5 -0
- data/spec/tabry/shells/bash_spec.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7733876522770c3037de86e663ddadd59cf1a86b2ddb1bc993934789e5b8d34a
|
4
|
+
data.tar.gz: 383673dc7f2ba427e70808fc08484829db28cd5b2c263b21ed1a4971ee2427be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f75ff33d1b2d3c9e959debc066a672687b906a64a7b414ed57091878cb4ede0ae815d18c563ea619be7ca148bc51c2a571d9cb4075ff4a10ca0c05e64a97cd
|
7
|
+
data.tar.gz: 29d82a30fe87411c11c97287bd6af5f1fd279bf2f1a1e44890273c7844d6dd5e0f35916bf4756f2c9fbfbc84f9e6a206862f8d73addbae14cce90666b2b16f89
|
data/lib/tabry/cli/flag_proxy.rb
CHANGED
@@ -11,9 +11,9 @@ module Tabry
|
|
11
11
|
|
12
12
|
attr_reader(*FIELDS.keys)
|
13
13
|
|
14
|
-
# Handled by
|
14
|
+
# Handled by tabry-bash/tabry-bash.sh/shell, we just return a symbol to
|
15
15
|
# communicate to tabry-bash
|
16
|
-
def options(_token)
|
16
|
+
def options(_token, _params)
|
17
17
|
[:directory]
|
18
18
|
end
|
19
19
|
|
@@ -11,9 +11,9 @@ module Tabry
|
|
11
11
|
|
12
12
|
attr_reader(*FIELDS.keys)
|
13
13
|
|
14
|
-
# Handled by
|
14
|
+
# Handled by tabry-bash/tabry-bash.sh/shell, we just return a symbol to
|
15
15
|
# communicate to tabry-bash
|
16
|
-
def options(_token)
|
16
|
+
def options(_token, _params)
|
17
17
|
[:file]
|
18
18
|
end
|
19
19
|
|
data/lib/tabry/options_finder.rb
CHANGED
data/lib/tabry/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,9 +9,9 @@ describe Tabry::Models::ConstOption do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "filters by prefix" do
|
12
|
-
expect(subject.options("")).to eq(%w[foobar])
|
13
|
-
expect(subject.options("f")).to eq(%w[foobar])
|
14
|
-
expect(subject.options("foo")).to eq(%w[foobar])
|
15
|
-
expect(subject.options("w")).to eq(%w[])
|
12
|
+
expect(subject.options("", {})).to eq(%w[foobar])
|
13
|
+
expect(subject.options("f", {})).to eq(%w[foobar])
|
14
|
+
expect(subject.options("foo", {})).to eq(%w[foobar])
|
15
|
+
expect(subject.options("w", {})).to eq(%w[])
|
16
16
|
end
|
17
17
|
end
|
@@ -11,6 +11,6 @@ describe Tabry::Models::DirOption do
|
|
11
11
|
# Handled by tabru=bash/tabry-bash.sh/shell, we just return a symbol to
|
12
12
|
# communicate to tabry-bash
|
13
13
|
it "returns a array with a symbol" do
|
14
|
-
expect(subject.options("whatever")).to eq([:directory])
|
14
|
+
expect(subject.options("whatever", {})).to eq([:directory])
|
15
15
|
end
|
16
16
|
end
|
@@ -11,6 +11,6 @@ describe Tabry::Models::FileOption do
|
|
11
11
|
# Handled by tabru=bash/tabry-bash.sh/shell, we just return a symbol to
|
12
12
|
# communicate to tabry-bash
|
13
13
|
it "returns a array with a symbol" do
|
14
|
-
expect(subject.options("whatever")).to eq([:file])
|
14
|
+
expect(subject.options("whatever", {})).to eq([:file])
|
15
15
|
end
|
16
16
|
end
|
@@ -39,9 +39,9 @@ describe Tabry::Models::OptionsList do
|
|
39
39
|
%w[d c b a]
|
40
40
|
]
|
41
41
|
subject.each_with_index do |opt, i|
|
42
|
-
expect(opt).to receive(:options).with("some-token").and_return(opts_results[i])
|
42
|
+
expect(opt).to receive(:options).with("some-token", {}).and_return(opts_results[i])
|
43
43
|
end
|
44
|
-
expect(subject.options("some-token")).to match_array(%w[a b c d foo bar waz ok 1])
|
44
|
+
expect(subject.options("some-token", {})).to match_array(%w[a b c d foo bar waz ok 1])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -11,9 +11,9 @@ describe Tabry::Models::ShellOption do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "filters by prefix" do
|
14
|
-
expect(subject.options("")).to match_array(%w[a a1 b])
|
15
|
-
expect(subject.options("a")).to match_array(%w[a a1])
|
16
|
-
expect(subject.options("a1")).to match_array(%w[a1])
|
17
|
-
expect(subject.options("a1 ")).to match_array(%w[])
|
14
|
+
expect(subject.options("", {})).to match_array(%w[a a1 b])
|
15
|
+
expect(subject.options("a", {})).to match_array(%w[a a1])
|
16
|
+
expect(subject.options("a1", {})).to match_array(%w[a1])
|
17
|
+
expect(subject.options("a1 ", {})).to match_array(%w[])
|
18
18
|
end
|
19
19
|
end
|
@@ -85,7 +85,7 @@ describe Tabry::OptionsFinder do
|
|
85
85
|
hash[:subcommand_stack] = hash.delete(:subs) || []
|
86
86
|
defaults = { mode: :subcommand, args: [], flags: {}, current_flag: nil, dashdash: nil }
|
87
87
|
result = Tabry::Result.new(config, Tabry::State.new(defaults.merge(hash)))
|
88
|
-
expect(described_class.options(result, token)).to match_array expected_options
|
88
|
+
expect(described_class.options(result, token, {})).to match_array expected_options
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -115,12 +115,12 @@ describe Tabry::OptionsFinder do
|
|
115
115
|
)
|
116
116
|
end
|
117
117
|
|
118
|
-
described_class.options(result, "abcd")
|
118
|
+
described_class.options(result, "abcd", {})
|
119
119
|
end
|
120
120
|
|
121
121
|
it "sets TABRY_AUTOCOMPLETE_STATE back to what it was before" do
|
122
122
|
ENV["TABRY_AUTOCOMPLETE_STATE"] = "foobar1234"
|
123
|
-
described_class.options(result, "foo")
|
123
|
+
described_class.options(result, "foo", {})
|
124
124
|
expect(ENV.fetch("TABRY_AUTOCOMPLETE_STATE", nil)).to eq("foobar1234")
|
125
125
|
end
|
126
126
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../../../lib/tabry/replty/builder'
|
2
|
+
require_relative '../../../lib/tabry/replty/base'
|
3
|
+
require_relative '../../../lib/tabry/config_builder'
|
4
|
+
|
5
|
+
module Tabry
|
6
|
+
module Specs
|
7
|
+
class TestRepl < Tabry::Replty::Base
|
8
|
+
def log
|
9
|
+
@log ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def foo
|
13
|
+
log << [:foo]
|
14
|
+
end
|
15
|
+
|
16
|
+
def bar
|
17
|
+
log << [:bar, args.waz, flags.ok]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe Tabry::Replty::Builder do
|
24
|
+
it 'calls the repl method for the subcommand' do
|
25
|
+
conf = Tabry::ConfigBuilder.build do |c|
|
26
|
+
sub :foo
|
27
|
+
sub :bar do
|
28
|
+
arg :waz
|
29
|
+
flag :ok
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
repl = Tabry::Specs::TestRepl.new
|
34
|
+
builder = Tabry::Replty::Builder.new(conf, repl)
|
35
|
+
expect(builder).to receive(:readline).and_return("bar waz --ok")
|
36
|
+
expect(builder).to receive(:readline).and_return(nil)
|
37
|
+
builder.run
|
38
|
+
end
|
39
|
+
end
|
data/spec/tabry/runner_spec.rb
CHANGED
@@ -28,7 +28,7 @@ describe Tabry::Runner do
|
|
28
28
|
it "runs OptionsFinder" do
|
29
29
|
res = instance_double(Tabry::Result)
|
30
30
|
expect(subject).to receive(:parse).with(%w[foo bar]).and_return res
|
31
|
-
expect(Tabry::OptionsFinder).to receive(:options).with(res, "waz").and_return %w[a b c]
|
31
|
+
expect(Tabry::OptionsFinder).to receive(:options).with(res, "waz", {}).and_return %w[a b c]
|
32
32
|
expect(subject.options(%w[foo bar], "waz")).to eq(%w[a b c])
|
33
33
|
end
|
34
34
|
end
|
@@ -23,6 +23,11 @@ describe Tabry::ShellTokenizer do
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
+
it "uses comppoint to correctly figures out whether we are still on the last token" do
|
27
|
+
expect(described_class.split_with_comppoint("jir add ", 7)).to eq(["jir", [], "add"])
|
28
|
+
expect(described_class.split_with_comppoint("jir add ", 8)).to eq(["jir", ["add"], ""])
|
29
|
+
end
|
30
|
+
|
26
31
|
it "supports tokens with argument (tab on command), yielding the last arg" do
|
27
32
|
expect(described_class.split_with_comppoint("abc", 2)).to eq([nil, [], "abc"])
|
28
33
|
end
|
@@ -30,13 +30,13 @@ describe Tabry::Shells::Bash do
|
|
30
30
|
describe '.generate' do
|
31
31
|
it 'tells bash to use tabry-bash with a import path to get completion options' do
|
32
32
|
result = described_class.generate("my-cmd", "/path/to/mycmd.tabry")
|
33
|
-
expect(result).to include("TABRY_IMPORTS_PATH=/path/to/mycmd.tabry _tabry_MY_CMD_completions_internal /
|
33
|
+
expect(result).to include("TABRY_IMPORTS_PATH=/path/to/mycmd.tabry _tabry_MY_CMD_completions_internal /")
|
34
34
|
expect(result).to include("complete -F _tabry_MY_CMD_completions my-cmd\n")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "takes a uniq_fn_id parameter to override the default function names" do
|
38
38
|
result = described_class.generate("my-cmd", "/path/to/mycmd.tabry", uniq_fn_id: "my cmd tabryv0.2.0")
|
39
|
-
expect(result).to include("TABRY_IMPORTS_PATH=/path/to/mycmd.tabry _tabry_MY_CMD_TABRYV0_2_0_completions_internal /
|
39
|
+
expect(result).to include("TABRY_IMPORTS_PATH=/path/to/mycmd.tabry _tabry_MY_CMD_TABRYV0_2_0_completions_internal /")
|
40
40
|
expect(result).to include("complete -F _tabry_MY_CMD_TABRYV0_2_0_completions my-cmd\n")
|
41
41
|
expect(result).to include("_tabry_MY_CMD_TABRYV0_2_0_completions_internal()")
|
42
42
|
end
|
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.6
|
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-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- spec/tabry/models/shell_option_spec.rb
|
204
204
|
- spec/tabry/models/subs_list_spec.rb
|
205
205
|
- spec/tabry/options_finder_spec.rb
|
206
|
+
- spec/tabry/replty/builder_spec.rb
|
206
207
|
- spec/tabry/result_spec.rb
|
207
208
|
- spec/tabry/runner_spec.rb
|
208
209
|
- spec/tabry/shell_tokenizer_spec.rb
|