2 ms·
This regex is the one I used to extract options from man pages, not to parse the command line (which is simply a wrapper around Python's shlex).
by idank 13y ago
This regex is the one I used to extract options from man pages, not to parse the command line (which is simply a wrapper around Python's shlex).
- mtdewcmu 13y agoI see. I started doing almost the exact same thing at one time. My goal was to create autocomplete rules. I think I used the output from the tool's --help or -? rather than manpages, and I would have been using awk and sed, since I never learned Python. Bash autocomplete specifications are messy, but you can sidestep a lot of the mess. You're allowed to run an arbitrary command to generate the completion list. I was envisioning some kind of standard option grammar that the autocomplete program would interpret for a given tool. The grammar would be partly generated automatically, but would likely need hand-tuning.