tabry 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/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/runner_spec.rb +1 -1
- data/spec/tabry/shell_tokenizer_spec.rb +5 -0
- data/spec/tabry/shells/bash_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c824df1e6a6631ef74c0d450831fbb665dec5f95fd9ea204b539ed1042225e5b
|
4
|
+
data.tar.gz: c4c88089e043818c58e38ea126a2eb40b9710e0e7b3204aa615c89e6cace9ca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a91bd4f7f95c2ec10fda6747329c66b7d276cf17e1852af2a3c32cb314914598fee712e88a429b094bf6b5ca8e2269d13c64af51433e2eba54384470c5ec52
|
7
|
+
data.tar.gz: 989588444d36596bf18310f35428b545d2489935469ad0fe58069f53f7f7e8bb19627720ada337c2f5b2b4917cb53b9471a0c00eb86e16f6e7b6b48fbef0c424
|
@@ -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
@@ -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
|
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.5
|
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-07
|
11
|
+
date: 2023-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|