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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87fa1708b1efb9ef81588017419bb6c63455ee786870f882783cf59f22ea462b
4
- data.tar.gz: f0822419f2a36d48148cf7cf0ecdbd195666e2c5fe284d2e8dd6a563976c0842
3
+ metadata.gz: c824df1e6a6631ef74c0d450831fbb665dec5f95fd9ea204b539ed1042225e5b
4
+ data.tar.gz: c4c88089e043818c58e38ea126a2eb40b9710e0e7b3204aa615c89e6cace9ca5
5
5
  SHA512:
6
- metadata.gz: de752dc58cefc4cc1caed94a4f0ae34758fdb40a9973f48ed5471b17fef517b0eecfbfd7e3735179793cce8d16d739d2cb2fe6d833c3f765f5c57e353dac1b7a
7
- data.tar.gz: 3e26e31d951fbc7f076b3c6e5b2c96eccfd1287c5469f84447ec549dc6aca51746dc193cbed36276b2e81dab67ce2bee8204cc0e8bb6b4010a07b284bac75f32
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 tabru=bash/tabry-bash.sh/shell, we just return a symbol to
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 tabru=bash/tabry-bash.sh/shell, we just return a symbol to
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
 
@@ -16,7 +16,7 @@ module Tabry
16
16
  end
17
17
  end
18
18
 
19
- def options(token, used:, params:)
19
+ def options(token, params, used:)
20
20
  to_a.map do |flag|
21
21
  if token&.start_with?("-") && flag.name_with_dashes.start_with?(token) && !used[flag.name]
22
22
  if params[:descriptions]
@@ -78,7 +78,7 @@ module Tabry
78
78
 
79
79
  result
80
80
  .sub_stack
81
- .map { |sub| sub.flags.options(token, used: state.flags, params: params) }
81
+ .map { |sub| sub.flags.options(token, params, used: state.flags) }
82
82
  .flatten(1)
83
83
  .uniq
84
84
  end
data/lib/tabry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tabry
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -55,6 +55,10 @@ describe Tabry::ConfigBuilder do
55
55
  {
56
56
  "description" => "Get tab completion for bash or zsh",
57
57
  "name" => "bash"
58
+ },
59
+ {
60
+ "description" => "Get tab completion for fish",
61
+ "name" => "fish"
58
62
  }
59
63
  ]
60
64
  }
@@ -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
@@ -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 /home/evan/dev/tabry/bin/tabry-bash \n")
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 /home/evan/dev/tabry/bin/tabry-bash \n")
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
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-19 00:00:00.000000000 Z
11
+ date: 2023-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug