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