]>
jfr.im git - yt-dlp.git/blob - devscripts/bash-completion.py
3 from os
.path
import dirname
as dirn
6 sys
.path
.insert(0, dirn(dirn(os
.path
.abspath(__file__
))))
9 BASH_COMPLETION_FILE
= "completions/bash/yt-dlp"
10 BASH_COMPLETION_TEMPLATE
= "devscripts/bash-completion.in"
13 def build_completion(opt_parser
):
15 for group
in opt_parser
.option_groups
:
16 for option
in group
.option_list
:
18 opts_flag
.append(option
.get_opt_string())
19 with open(BASH_COMPLETION_TEMPLATE
) as f
:
21 with open(BASH_COMPLETION_FILE
, "w") as f
:
22 # just using the special char
23 filled_template
= template
.replace("{{flags}}", " ".join(opts_flag
))
24 f
.write(filled_template
)
27 parser
= yt_dlp
.parseOpts()[0]
28 build_completion(parser
)