]> jfr.im git - yt-dlp.git/blame - devscripts/bash_completion.py
little correction on the readme
[yt-dlp.git] / devscripts / bash_completion.py
CommitLineData
bdff3455 1#!/usr/bin/env python2
2import youtube_dl
3
4BASH_COMPLETION_FILE = "youtube-dl.bash_completion"
5BASH_COMPLETION_TEMPLATE = "devscripts/bash_completion.template"
6
7def build_completion(opt_parser):
8 opts_flag = []
9 for group in opt_parser.option_groups:
10 for option in group.option_list:
11 #for every long flag
12 opts_flag.append(option.get_opt_string())
13 with open(BASH_COMPLETION_TEMPLATE) as f:
14 template = f.read()
15 with open(BASH_COMPLETION_FILE, "w") as f:
16 #just using the special char
17 print opts_flag
18 filled_template = template.replace("{{flags}}", " ".join(opts_flag))
19 f.write(filled_template)
20
21parser = youtube_dl.parseOpts()[0]
22build_completion(parser)