]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
a9d2f7e8 | 2 | import os |
a9d2f7e8 | 3 | import sys |
4 | ||
e5a998f3 | 5 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
6 | ||
7a5c1cfe | 7 | import yt_dlp |
bdff3455 | 8 | |
359d6d86 | 9 | BASH_COMPLETION_FILE = "completions/bash/yt-dlp" |
a4680a59 | 10 | BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.in" |
bdff3455 | 11 | |
5f6a1245 | 12 | |
bdff3455 | 13 | def build_completion(opt_parser): |
14 | opts_flag = [] | |
15 | for group in opt_parser.option_groups: | |
16 | for option in group.option_list: | |
5f6a1245 | 17 | # for every long flag |
bdff3455 | 18 | opts_flag.append(option.get_opt_string()) |
19 | with open(BASH_COMPLETION_TEMPLATE) as f: | |
20 | template = f.read() | |
21 | with open(BASH_COMPLETION_FILE, "w") as f: | |
5f6a1245 | 22 | # just using the special char |
bdff3455 | 23 | filled_template = template.replace("{{flags}}", " ".join(opts_flag)) |
24 | f.write(filled_template) | |
25 | ||
582be358 | 26 | |
c1714454 | 27 | parser = yt_dlp.parseOpts(ignore_config_files=True)[0] |
bdff3455 | 28 | build_completion(parser) |