]>
Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/bash-completion.py
cd26cc0895d033af03541f48815e8dad23f5161d
2 from __future__
import unicode_literals
5 from os
.path
import dirname
as dirn
8 sys
.path
.append(dirn(dirn((os
.path
.abspath(__file__
)))))
11 BASH_COMPLETION_FILE
= "youtube-dl.bash-completion"
12 BASH_COMPLETION_TEMPLATE
= "devscripts/bash-completion.in"
15 def build_completion(opt_parser
):
17 for group
in opt_parser
.option_groups
:
18 for option
in group
.option_list
:
20 opts_flag
.append(option
.get_opt_string())
21 with open(BASH_COMPLETION_TEMPLATE
) as f
:
23 with open(BASH_COMPLETION_FILE
, "w") as f
:
24 # just using the special char
25 filled_template
= template
.replace("{{flags}}", " ".join(opts_flag
))
26 f
.write(filled_template
)
28 parser
= youtube_dl
.parseOpts()[0]
29 build_completion(parser
)