File tree Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -31,21 +31,19 @@ def completion_flag_names
3131 flags . map ( &:name ) + flags . map ( &:short )
3232 end
3333
34- def completion_flag_whitelist
35- flags . map ( &:allowed ) . flatten
34+ def completion_allowed_args
35+ flags . map ( &:allowed ) . flatten + args . map ( & :allowed ) . flatten
3636 end
3737
3838 def completion_words ( with_version : false )
3939 trivial_flags = %w[ --help -h ]
4040 trivial_flags += %w[ --version -v ] if with_version
4141 all = (
4242 command_names + trivial_flags +
43- completion_flag_names +
44- completion_flag_whitelist
43+ completion_flag_names + completion_allowed_args
4544 )
4645
4746 all += completions if completions
48- all += allowed if allowed
4947 all . compact . uniq . sort
5048 end
5149
Original file line number Diff line number Diff line change 1+ ---
2+ download:
3+ - "--help"
4+ - "--method"
5+ - "--role"
6+ - "--version"
7+ - "-h"
8+ - "-v"
9+ - '22'
10+ - '3000'
11+ - '80'
12+ - admin
13+ - get
14+ - https
15+ - post
16+ - ssh
17+ - user
Original file line number Diff line number Diff line change 3838 end
3939 end
4040 end
41+
42+ context "with a command that uses whitelist args" do
43+ let ( :fixture ) { :completions_whitelist }
44+
45+ describe '#completion_data' do
46+ it "returns a data structure that includes thw whitelist" do
47+ expect ( subject . completion_data . to_yaml )
48+ . to match_approval ( "completions/whitelist" )
49+ end
50+ end
51+ end
4152end
Original file line number Diff line number Diff line change 161161 - long : --verbose
162162 short : -v
163163
164+ :completions_whitelist :
165+ name : download
166+ args :
167+ - name : protocol
168+ allowed : [https, ssh]
169+ - name : port
170+ allowed : ["80", "22", "3000"]
171+ flags :
172+ - long : --role
173+ arg : name
174+ allowed : [user, admin]
175+ - long : --method
176+ arg : name
177+ allowed : [get, post]
178+
164179:custom_header :
165180 name : check
You can’t perform that action at this time.
0 commit comments