]>
Commit | Line | Data |
---|---|---|
a9d2f7e8 | 1 | #!/usr/bin/env python |
dcddc10a PH |
2 | from __future__ import unicode_literals |
3 | ||
a9d2f7e8 | 4 | import os |
5 | from os.path import dirname as dirn | |
6 | import sys | |
7 | ||
8 | sys.path.append(dirn(dirn((os.path.abspath(__file__))))) | |
bdff3455 | 9 | import youtube_dl |
10 | ||
4c1d273e | 11 | BASH_COMPLETION_FILE = "youtube-dl.bash-completion" |
a4680a59 | 12 | BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.in" |
bdff3455 | 13 | |
5f6a1245 | 14 | |
bdff3455 | 15 | def build_completion(opt_parser): |
16 | opts_flag = [] | |
17 | for group in opt_parser.option_groups: | |
18 | for option in group.option_list: | |
5f6a1245 | 19 | # for every long flag |
bdff3455 | 20 | opts_flag.append(option.get_opt_string()) |
21 | with open(BASH_COMPLETION_TEMPLATE) as f: | |
22 | template = f.read() | |
23 | with open(BASH_COMPLETION_FILE, "w") as f: | |
5f6a1245 | 24 | # just using the special char |
bdff3455 | 25 | filled_template = template.replace("{{flags}}", " ".join(opts_flag)) |
26 | f.write(filled_template) | |
27 | ||
28 | parser = youtube_dl.parseOpts()[0] | |
29 | build_completion(parser) |