Skip to content

Commit 91f4f74

Browse files
authored
Merge pull request #100 from bashly-framework/rollback
Rollback
2 parents 5e78eec + afe2c52 commit 91f4f74

24 files changed

+344
-334
lines changed

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AGENTS.md
2+
3+
## Notes
4+
5+
- `CHANGELOG.md` is generated using `git changelog`; do not edit it manually.

CHANGELOG.md

Lines changed: 43 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,203 +1,161 @@
11
Changelog
22
========================================
33

4-
v0.7.4 - 2026-02-19
5-
----------------------------------------
6-
7-
- Fix completion escaping [`dce16c3`](https://github.com/bashly-framework/completely/commit/dce16c3)
8-
- Refactor template filter function [`834ed78`](https://github.com/bashly-framework/completely/commit/834ed78)
9-
- Update completions installer paths [`338d567`](https://github.com/bashly-framework/completely/commit/338d567)
10-
- Compare [`v0.7.3..v0.7.4`](https://github.com/bashly-framework/completely/compare/v0.7.3..v0.7.4)
11-
12-
13-
v0.7.3 - 2025-09-24
14-
----------------------------------------
15-
16-
- Add support for reading config from stdin and writing to stdout [`764fb36`](https://github.com/bashly-framework/completely/commit/764fb36)
17-
- Fix repeating final completion [`0029c4e`](https://github.com/bashly-framework/completely/commit/0029c4e)
18-
- Refactor installer with new io / string builders [`cb91679`](https://github.com/bashly-framework/completely/commit/cb91679)
19-
- Add support for `generate --install` [`c5a877e`](https://github.com/bashly-framework/completely/commit/c5a877e)
20-
- Compare [`v0.7.2..v0.7.3`](https://github.com/bashly-framework/completely/compare/v0.7.2..v0.7.3)
21-
22-
234
v0.7.2 - 2025-08-04
245
----------------------------------------
256

26-
- Fix JSON schema [`3cc3ef6`](https://github.com/bashly-framework/completely/commit/3cc3ef6)
27-
- Drop support for Ruby 3.0 and 3.1 [`7ff8bd8`](https://github.com/bashly-framework/completely/commit/7ff8bd8)
28-
- Compare [`v0.7.1..v0.7.2`](https://github.com/bashly-framework/completely/compare/v0.7.1..v0.7.2)
7+
- Fix JSON schema
8+
- Drop support for Ruby 3.0 and 3.1
299

3010

3111
v0.7.1 - 2025-04-04
3212
----------------------------------------
3313

34-
- Add support for modifying the `complete` command options [`690c264`](https://github.com/bashly-framework/completely/commit/690c264)
35-
- Compare [`v0.7.0..v0.7.1`](https://github.com/bashly-framework/completely/compare/v0.7.0..v0.7.1)
14+
- Add support for modifying the `complete` command options
3615

3716

3817
v0.7.0 - 2024-11-29
3918
----------------------------------------
4019

41-
- Update instructions and template for obtaining list of git branches [`8cdfabd`](https://github.com/bashly-framework/completely/commit/8cdfabd)
42-
- Add support for nested configuration [`742e3cd`](https://github.com/bashly-framework/completely/commit/742e3cd)
43-
- Add `completely init --nested` and explain nested syntax in the README [`f1e17ed`](https://github.com/bashly-framework/completely/commit/f1e17ed)
44-
- Compare [`v0.6.3..v0.7.0`](https://github.com/bashly-framework/completely/compare/v0.6.3..v0.7.0)
20+
- Update instructions and template for obtaining list of git branches
21+
- Add support for nested configuration
22+
- Add `completely init --nested` and explain nested syntax in the README
4523

4624

4725
v0.6.3 - 2024-07-05
4826
----------------------------------------
4927

50-
- Allow using colon, semicolon and equal sign in completions [`a9e6a6e`](https://github.com/bashly-framework/completely/commit/a9e6a6e)
51-
- Check output with shfmt [`3f7ae7e`](https://github.com/bashly-framework/completely/commit/3f7ae7e)
52-
- Revert wordbreak (colon) patch [`24f9d3d`](https://github.com/bashly-framework/completely/commit/24f9d3d)
53-
- Compare [`v0.6.2..v0.6.3`](https://github.com/bashly-framework/completely/compare/v0.6.2..v0.6.3)
28+
- Allow using colon, semicolon and equal sign in completions
29+
- Check output with shfmt
30+
- Revert wordbreak (colon) patch
5431

5532

5633
v0.6.2 - 2024-02-08
5734
----------------------------------------
5835

59-
- Update possible completions installation directories [`2bc93a7`](https://github.com/bashly-framework/completely/commit/2bc93a7)
60-
- Build docker images automatically [`4d20dfd`](https://github.com/bashly-framework/completely/commit/4d20dfd)
61-
- Compare [`v0.6.1..v0.6.2`](https://github.com/bashly-framework/completely/compare/v0.6.1..v0.6.2)
36+
- Update possible completions installation directories
37+
- Build docker images automatically
6238

6339

6440
v0.6.1 - 2023-06-23
6541
----------------------------------------
6642

67-
- Add ability to uninstall a completion script [`67b6715`](https://github.com/bashly-framework/completely/commit/67b6715)
68-
- Compare [`v0.6.0..v0.6.1`](https://github.com/bashly-framework/completely/compare/v0.6.0..v0.6.1)
43+
- Add ability to uninstall a completion script
6944

7045

7146
v0.6.0 - 2023-06-23
7247
----------------------------------------
7348

74-
- Refactor install command and add an Installer model [`b1341fa`](https://github.com/bashly-framework/completely/commit/b1341fa)
75-
- Drop support for Ruby 2.7 [`151eff1`](https://github.com/bashly-framework/completely/commit/151eff1)
76-
- Change exception classes [`3ce16ac`](https://github.com/bashly-framework/completely/commit/3ce16ac)
77-
- Compare [`v0.5.4..v0.6.0`](https://github.com/bashly-framework/completely/compare/v0.5.4..v0.6.0)
49+
- Refactor install command and add an Installer model
50+
- Drop support for Ruby 2.7
51+
- Change exception classes
7852

7953

8054
v0.5.4 - 2023-04-21
8155
----------------------------------------
8256

83-
- Add `completely install` command [`2fbd879`](https://github.com/bashly-framework/completely/commit/2fbd879)
84-
- Compare [`v0.5.3..v0.5.4`](https://github.com/bashly-framework/completely/compare/v0.5.3..v0.5.4)
57+
- Add `completely install` command
8558

8659

8760
v0.5.3 - 2023-01-31
8861
----------------------------------------
8962

90-
- Upgrade dependencies [`211166a`](https://github.com/bashly-framework/completely/commit/211166a)
91-
- Compare [`v0.5.2..v0.5.3`](https://github.com/bashly-framework/completely/compare/v0.5.2..v0.5.3)
63+
- Upgrade dependencies
9264

9365

9466
v0.5.2 - 2022-12-02
9567
----------------------------------------
9668

97-
- Improve test command output and allow multiple complines in one run [`e924571`](https://github.com/bashly-framework/completely/commit/e924571)
98-
- Compare [`v0.5.1..v0.5.2`](https://github.com/bashly-framework/completely/compare/v0.5.1..v0.5.2)
69+
- Improve test command output and allow multiple complines in one run
9970

10071

10172
v0.5.1 - 2022-11-28
10273
----------------------------------------
10374

104-
- Refactor with rubocop [`42b996d`](https://github.com/bashly-framework/completely/commit/42b996d)
105-
- Fix broken script when wildcards follow the first word [`63b77d1`](https://github.com/bashly-framework/completely/commit/63b77d1)
106-
- Show warning when running the test command on an invalid file [`de7ede0`](https://github.com/bashly-framework/completely/commit/de7ede0)
107-
- Compare [`v0.5.0..v0.5.1`](https://github.com/bashly-framework/completely/compare/v0.5.0..v0.5.1)
75+
- Refactor with rubocop
76+
- Fix broken script when wildcards follow the first word
77+
- Show warning when running the test command on an invalid file
10878

10979

11080
v0.5.0 - 2022-09-04
11181
----------------------------------------
11282

113-
- Add docker release [`39acd6e`](https://github.com/bashly-framework/completely/commit/39acd6e)
114-
- Fix shellcheck SC2162 in the generated script [`9e703ec`](https://github.com/bashly-framework/completely/commit/9e703ec)
115-
- Fix shellcheck SC2124 in the generated script [`2d23c51`](https://github.com/bashly-framework/completely/commit/2d23c51)
116-
- Hide flag completion unless input ends with a hyphen [`c15d705`](https://github.com/bashly-framework/completely/commit/c15d705)
117-
- Compare [`v0.4.3..v0.5.0`](https://github.com/bashly-framework/completely/compare/v0.4.3..v0.5.0)
83+
- Add docker release
84+
- Fix shellcheck SC2162 in the generated script
85+
- Fix shellcheck SC2124 in the generated script
86+
- Hide flag completion unless input ends with a hyphen
11887

11988

12089
v0.4.3 - 2022-07-14
12190
----------------------------------------
12291

123-
- Fix file/folder completion when they contain spaces [`9dea691`](https://github.com/bashly-framework/completely/commit/9dea691)
124-
- Compare [`v0.4.2..v0.4.3`](https://github.com/bashly-framework/completely/compare/v0.4.2..v0.4.3)
92+
- Fix file/folder completion when they contain spaces
12593

12694

12795
v0.4.2 - 2022-05-27
12896
----------------------------------------
12997

130-
- Allow keeping the test script with --keep [`20d9b15`](https://github.com/bashly-framework/completely/commit/20d9b15)
131-
- Compare [`v0.4.1..v0.4.2`](https://github.com/bashly-framework/completely/compare/v0.4.1..v0.4.2)
98+
- Allow keeping the test script with --keep
13299

133100

134101
v0.4.1 - 2022-05-21
135102
----------------------------------------
136103

137-
- Remove support for arbitrary script test to fix zsh incompatibilities [`9e3e6d9`](https://github.com/bashly-framework/completely/commit/9e3e6d9)
138-
- Compare [`v0.4.0..v0.4.1`](https://github.com/bashly-framework/completely/compare/v0.4.0..v0.4.1)
104+
- Remove support for arbitrary script test to fix zsh incompatibilities
139105

140106

141107
v0.4.0 - 2022-05-21
142108
----------------------------------------
143109

144-
- Improve template [`8172be2`](https://github.com/bashly-framework/completely/commit/8172be2)
145-
- Refactor CLI commands [`1fced36`](https://github.com/bashly-framework/completely/commit/1fced36)
146-
- Add Tester class for testing any completions script [`986f4d1`](https://github.com/bashly-framework/completely/commit/986f4d1)
147-
- Add tester CLI command [`09e91ee`](https://github.com/bashly-framework/completely/commit/09e91ee)
148-
- Add support for middle wildcard for --flag args completions [`8d25207`](https://github.com/bashly-framework/completely/commit/8d25207)
149-
- Add COMPLETELY_DEBUG environment setting [`44c00a1`](https://github.com/bashly-framework/completely/commit/44c00a1)
150-
- Allow setting the CONFIG_PATH argument via the COMPLETELY_CONFIG_PATH environment variable [`8ef65e1`](https://github.com/bashly-framework/completely/commit/8ef65e1)
151-
- Allow setting the SCRIPT_PATH argument via the COMPLETELY_SCRIPT_PATH environment variable [`a484ff4`](https://github.com/bashly-framework/completely/commit/a484ff4)
152-
- Compare [`v0.3.1..v0.4.0`](https://github.com/bashly-framework/completely/compare/v0.3.1..v0.4.0)
110+
- Improve template
111+
- Refactor CLI commands
112+
- Add Tester class for testing any completions script
113+
- Add tester CLI command
114+
- Add support for middle wildcard for --flag args completions
115+
- Add COMPLETELY_DEBUG environment setting
116+
- Allow setting the CONFIG_PATH argument via the COMPLETELY_CONFIG_PATH environment variable
117+
- Allow setting the SCRIPT_PATH argument via the COMPLETELY_SCRIPT_PATH environment variable
153118

154119

155120
v0.3.1 - 2022-02-20
156121
----------------------------------------
157122

158-
- Fix Psych 4 errors for Ruby 3.1 [`2fb9a73`](https://github.com/bashly-framework/completely/commit/2fb9a73)
159-
- Compare [`v0.3.0..v0.3.1`](https://github.com/bashly-framework/completely/compare/v0.3.0..v0.3.1)
123+
- Fix Psych 4 errors for Ruby 3.1
160124

161125

162126
v0.3.0 - 2022-01-28
163127
----------------------------------------
164128

165-
- Fix generated script for zsh compatibility [`d19369b`](https://github.com/bashly-framework/completely/commit/d19369b)
166-
- Compare [`v0.2.0..v0.3.0`](https://github.com/bashly-framework/completely/compare/v0.2.0..v0.3.0)
129+
- Fix generated script for zsh compatibility
167130

168131

169132
v0.2.0 - 2021-09-03
170133
----------------------------------------
171134

172-
- Improve generated code to support local completions [`3518434`](https://github.com/bashly-framework/completely/commit/3518434)
173-
- Compare [`v0.1.3..v0.2.0`](https://github.com/bashly-framework/completely/compare/v0.1.3..v0.2.0)
135+
- Improve generated code to support local completions
174136

175137

176138
v0.1.3 - 2021-07-21
177139
----------------------------------------
178140

179-
- Fix function name when only spaced patterns are configured [`2e14ec2`](https://github.com/bashly-framework/completely/commit/2e14ec2)
180-
- Compare [`v0.1.2..v0.1.3`](https://github.com/bashly-framework/completely/compare/v0.1.2..v0.1.3)
141+
- Fix function name when only spaced patterns are configured
181142

182143

183144
v0.1.2 - 2021-07-20
184145
----------------------------------------
185146

186-
- Add ability to generate a function that prints the script [`22de124`](https://github.com/bashly-framework/completely/commit/22de124)
187-
- Compare [`v0.1.1..v0.1.2`](https://github.com/bashly-framework/completely/compare/v0.1.1..v0.1.2)
147+
- Add ability to generate a function that prints the script
188148

189149

190150
v0.1.1 - 2021-07-20
191151
----------------------------------------
192152

193-
- Fix missing VERSION error [`e6f0ac1`](https://github.com/bashly-framework/completely/commit/e6f0ac1)
194-
- Compare [`v0.1.0..v0.1.1`](https://github.com/bashly-framework/completely/compare/v0.1.0..v0.1.1)
153+
- Fix missing VERSION error
195154

196155

197156
v0.1.0 - 2021-07-20
198157
----------------------------------------
199158

200-
- Initial version [`bcd598c`](https://github.com/bashly-framework/completely/commit/bcd598c)
201-
- Compare [`v0.1.0`](https://github.com/bashly-framework/completely/compare/v0.1.0)
159+
- Initial version
202160

203161

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ FROM dannyben/alpine-ruby:3.3.3
33
ENV PS1="\n\n>> completely \W \$ "
44
WORKDIR /app
55

6-
RUN gem install completely --version 0.7.4
6+
RUN gem install completely --version 0.7.3
77

88
ENTRYPOINT ["completely"]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ mygit:
169169
The `2> /dev/null` is used so that if the command is executed in a directory
170170
without a git repository, it will still behave as expected.
171171

172+
### Completion scope and limitations
173+
174+
- Completion words are treated as whitespace-delimited tokens.
175+
- Literal completion phrases that contain spaces are not supported as a single completion item.
176+
- Quotes and other special shell characters in literal completion words are not escaped automatically.
177+
- Dynamic `$(...)` completion commands should output plain whitespace-delimited words.
178+
172179
### Suggesting flag arguments
173180

174181
Adding a `*` wildcard in the middle of a pattern can be useful for suggesting

lib/completely/pattern.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,17 @@ def compgen
4949
@compgen ||= compgen!
5050
end
5151

52+
def filename_action?
53+
actions.include?('-A file') || actions.include?('-A directory')
54+
end
55+
5256
private
5357

5458
def compgen!
5559
result = []
5660
result << actions.join(' ').to_s if actions.any?
57-
result << %[-W "$(#{function_name} #{quoted_words.join ' '})"] if words.any?
61+
result << %[-W "$(#{function_name} "#{words.join ' '}")"] if words.any?
5862
result.any? ? result.join(' ') : nil
5963
end
60-
61-
def quoted_words
62-
@quoted_words ||= words.map { |word| %("#{escape_for_double_quotes word}") }
63-
end
64-
65-
def escape_for_double_quotes(word)
66-
word.gsub(/["\\]/, '\\\\\&')
67-
end
6864
end
6965
end

lib/completely/templates/template.erb

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,38 @@
55
# Modifying it manually is not recommended
66

77
<%= function_name %>_filter() {
8-
local words=("$@")
8+
local words="$1"
99
local cur=${COMP_WORDS[COMP_CWORD]}
1010
local result=()
11-
local want_options=0
1211

1312
# words the user already typed (excluding the command itself)
1413
local used=()
1514
if ((COMP_CWORD > 1)); then
1615
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
1716
fi
1817

19-
# Completing an option: offer everything.
20-
# Completing a non-option: drop options and already-used words.
21-
[[ "${cur:0:1}" == "-" ]] && want_options=1
22-
for word in "${words[@]}"; do
23-
if ((!want_options)); then
18+
if [[ "${cur:0:1}" == "-" ]]; then
19+
# Completing an option: offer everything (including options)
20+
echo "$words"
21+
22+
else
23+
# Completing a non-option: offer only non-options,
24+
# and don't re-offer ones already used earlier in the line.
25+
for word in $words; do
2426
[[ "${word:0:1}" == "-" ]] && continue
2527

28+
local seen=0
2629
for u in "${used[@]}"; do
2730
if [[ "$u" == "$word" ]]; then
28-
continue 2
31+
seen=1
32+
break
2933
fi
3034
done
31-
fi
32-
33-
# compgen -W expects shell-escaped words in one space-delimited string.
34-
printf -v word '%q' "$word"
35-
result+=("$word")
36-
done
35+
((!seen)) && result+=("$word")
36+
done
3737

38-
echo "${result[*]}"
38+
echo "${result[*]}"
39+
fi
3940
}
4041

4142
<%= function_name %>() {
@@ -59,6 +60,9 @@
5960
% patterns.each do |pattern|
6061
% next if pattern.empty?
6162
<%= pattern.case_string %>)
63+
% if pattern.filename_action?
64+
compopt -o filenames 2>/dev/null
65+
% end
6266
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen <%= pattern.compgen %> -- "$cur")
6367
;;
6468

lib/completely/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Completely
2-
VERSION = '0.7.4'
2+
VERSION = '0.7.3'
33
end

0 commit comments

Comments
 (0)