Debian Codegraph @

sh-completion/gen-completions

raw
1 #!/usr/bin/env lua
2
3 local argparse = require "argparse"
4
5 local parser = argparse "highlight"
6 :add_help(false)
7
8 parser:argument "file"
9 :args "*"
10
11 parser:option "-B --batch-recursive"
12 :description "convert all matching files, searches subdirs (example: -B '*.cpp')"
13 parser:option "-D --data-dir"
14 :description "set path to data directory"
15 parser:option "--config-file"
16 :description "set path to a lang or theme file"
17 parser:option "-d --outdir"
18 :description "name of output directory"
19 parser:flag "-h"
20 :description "print help and exit"
21 parser:option "--help"
22 :description "print help or a topic description"
23 :args "?"
24 :choices {"syntax", "theme", "plugin", "config", "test", "lsp"}
25 parser:option "-i --input"
26 :description "name of single input file"
27 parser:option "-o --output"
28 :description "name of single output file"
29 parser:flag "-P --progress"
30 :description "print progress bar in batch mode"
31 parser:flag "-q --quiet"
32 :description "suppress progress info in batch mode"
33 parser:option "-S --syntax"
34 :description "specify type of source code or syntax file path"
35 parser:option "--syntax-by-name"
36 :description "specify type of source code by given name"
37 parser:flag "--syntax-supported"
38 :description "test if the given syntax can be loaded"
39 parser:flag "-v --verbose"
40 :description "print debug info; repeat to show more information"
41 :count "*"
42 parser:option "--force"
43 :description "generate output if input syntax is unknown"
44 :args "?"
45 parser:option "--list-scripts"
46 :description "list installed scripts with given type"
47 :choices {"langs", "themes", "plugins"}
48 parser:option "--list-cat"
49 :description "filter the scripts by the given categories (example: --list-cat='source;script')"
50 parser:option "--max-size"
51 :description "set maximum input file size (examples: 512M, 1G; default: 256M)"
52 parser:option "--plug-in"
53 :description "execute Lua plug-in script; repeat option to execute multiple plug-ins"
54 :count "*"
55 parser:option "--plug-in-param"
56 :description "set plug-in input parameter"
57 parser:flag "--print-config"
58 :description "print path configuration"
59 parser:flag "--print-style"
60 :description "print stylesheet only (see --style-outfile)"
61 parser:option "--skip"
62 :description "ignore listed unknown file types (Example: --skip='bak;c~;h~')"
63 parser:flag "--stdout"
64 :description "output to stdout (batch mode, --print-style)"
65 parser:flag "--validate-input"
66 :description "test if input is text, remove Unicode BOM"
67 parser:flag "--version"
68 :description "print version and copyright information"
69 parser:option "-O --out-format"
70 :description "output file in given format"
71 :choices {"html", "xhtml", "latex", "tex", "odt", "rtf", "ansi", "xterm256", "truecolor", "bbcode", "pango", "svg"}
72 parser:option "-c --style-outfile"
73 :description "name of style file or print to stdout, if 'stdout' is given as file argument"
74 parser:option "-e --style-infile"
75 :description "to be included in style-outfile (deprecated) use a plug-in file instead"
76 parser:flag "-f --fragment"
77 :description "omit document header and footer"
78 parser:option "-F --reformat"
79 :description "reformats and indents output in given style"
80 :choices {"allman", "gnu", "google", "horstmann", "java", "kr", "linux", "lisp", "mozilla", "otbs", "pico", "vtk", "ratliff", "stroustrup", "webkit", "whitesmith"}
81 parser:flag "-I --include-style"
82 :description "include style definition in output file"
83 parser:option "-J --line-length"
84 :description "line length before wrapping (see -V, -W)"
85 parser:option "-j --line-number-length"
86 :description "line number width incl. left padding (default: 5)"
87 parser:option "--line-range"
88 :description "output only lines from number <start> to <end>"
89 parser:option "-k --font"
90 :description "set font (specific to output format)"
91 parser:option "-K --font-size"
92 :description "set font size (specific to output format)"
93 :args "?"
94 parser:flag "-l --line-numbers"
95 :description "print line numbers in output file"
96 parser:option "-m --line-number-start"
97 :description "start line numbering with cnt (assumes -l)"
98 parser:option "-s --style"
99 :description "set colour style (theme) or theme file path"
100 parser:option "-t --replace-tabs"
101 :description "replace tabs by <num> spaces"
102 parser:option "-T --doc-title"
103 :description "document title"
104 parser:option "-u --encoding"
105 :description "set output encoding which matches input file encoding; omit encoding info if set to NONE"
106 parser:flag "-V --wrap-simple"
107 :description "wrap lines after 80 (default) characters w/o indenting function parameters and statements"
108 parser:flag "-W --wrap"
109 :description "wrap lines after 80 (default) characters"
110 parser:flag "--wrap-no-numbers"
111 :description "omit line numbers of wrapped lines (assumes -l)"
112 parser:flag "-z --zeroes"
113 :description "pad line numbers with 0's"
114 parser:flag "--isolate"
115 :description "output each syntax token separately (verbose output)"
116 parser:flag "--keep-injections"
117 :description "output plug-in injections in spite of -f"
118 parser:option "--kw-case"
119 :description "change case of case insensitive keywords to given case"
120 :choices {"upper", "lower", "capitalize"}
121 parser:option "--no-trailing-nl"
122 :description "omit trailing newline. If mode is empty-file, omit only for empty input"
123 :args "?"
124 :choices {"empty-file"}
125 parser:flag "--no-version-info"
126 :description "omit version info comment"
127 parser:flag "-a --anchors"
128 :description "attach anchor to line numbers"
129 parser:option "-y --anchor-prefix"
130 :description "set anchor name prefix"
131 parser:flag "-N --anchor-filename"
132 :description "use input file name as anchor prefix"
133 parser:flag "-C --print-index"
134 :description "print index with hyperlinks to output files"
135 parser:flag "-n --ordered-list"
136 :description "print lines as ordered list items"
137 parser:option "--class-name"
138 :description "set CSS class name prefix; omit class name if set to NONE"
139 parser:flag "--inline-css"
140 :description "output CSS within each tag (verbose output)"
141 parser:flag "--enclose-pre"
142 :description "enclose fragmented output with pre tag (assumes -f)"
143 parser:flag "-b --babel"
144 :description "disable Babel package shorthands"
145 parser:flag "-r --replace-quotes"
146 :description "replace double quotes by \\dq{}"
147 parser:flag "--beamer"
148 :description "adapt output for the Beamer package"
149 parser:flag "--pretty-symbols"
150 :description "improve appearance of brackets and other symbols"
151 parser:flag "--page-color"
152 :description "include page color attributes"
153 parser:option "-x --page-size"
154 :description "set page size"
155 :choices {"a3", "a4", "a5", "b4", "b5", "b6", "letter"}
156 parser:flag "--char-styles"
157 :description "include character stylesheets"
158 parser:flag "--height"
159 :description "set image height (units allowed)"
160 parser:flag "--width"
161 :description "set image width (see --height)"
162 parser:option "--canvas"
163 :description "set background colour padding (default: 80)"
164 :args "?"
165 parser:option "--ls-profile"
166 :description "read LSP configuration from lsp.conf"
167 parser:option "--ls-delay"
168 :description "set server initialization delay"
169 parser:option "--ls-exec"
170 :description "set server executable name"
171 parser:option "--ls-option"
172 :description "set server CLI option (can be repeated)"
173 :count "*"
174 parser:flag "--ls-hover"
175 :description "execute hover requests (HTML output only)"
176 parser:flag "--ls-semantic"
177 :description "retrieve semantic token types (requires LSP 3.16)"
178 parser:option "--ls-syntax"
179 :description "set syntax which is understood by the server"
180 parser:flag "--ls-syntax-error"
181 :description "retrieve syntax error information (assumes --ls-hover or --ls-semantic)"
182 parser:option "--ls-workspace"
183 :description "set workspace directory to init. the server"
184 parser:option "--ls-legacy"
185 :description "do not require a server capabilities response"
186 parser:option "--service-mode"
187 :description "run in service mode, not stopping until signaled"
188
189 local p = argparse "gen-completions"
190 p:argument "shell"
191 :choices {"bash", "zsh", "fish"}
192
193 local shell = p:parse().shell
194
195 if shell == "bash" then
196 io.write(parser:get_bash_complete())
197 elseif shell == "zsh" then
198 io.write(parser:get_zsh_complete())
199 else
200 io.write(parser:get_fish_complete())
201 end