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