scspell
scspell copied to clipboard
scspell should support directory traversal
I think it'd be handy for scspell to have directory-recursing abilities. By way of illustration, here's my attempt at it for one project:
https://github.com/chapel-lang/chapel/blob/master/util/chplspell
All the complexity of that script is in service of two user conveniences:
-
The script has a built in default set of directories and file globs to search for within them, and
-
If any files or directories are given on the command line, they are used as the base of the search instead of the default ones.
This way, the user can just type chplspell
and get all the right
files in the tree spell-checked, with the right dictionaries and
options.
If this functionality were moved inside scspell, then this script could be replaced by effectively a one-liner, invoking scspell with a description of those defaults and passing through the rest of the commandline. And then any other projects that want to use scspell in a similar manner would only need their own similar one-liner instead of a complex script.
I don't know what would be the best interface for that. The two alternatives I've thought of are:
- Pass everything as commandline arguments.
- Pass everything through a config file.
In the first alternative, that "one-liner" would be a very long line, like the following (more generic files and directories than in the above script):
#!/bin/bash
exec scspell --defdir doc --defdir man --defdir src \
--defglob "*.c" --defglob "*.h" --defglob "*.cpp" \
--use-builtin-base-dict \
--relative-to $PROJ_HOME \
--override-dictionary $PROJ_HOME/.scspell/dictionary \
"$@"
In the second alternative, it would be a simpler one-liner. The config file would specify all the other options from the command line above.
#!/bin/bash
exec scspell --project-config $PROJ_HOME/.scspell/$PROJ.scspell.conf "$@"
Presumably using ConfigParser.
I'm not sure how to cleanly associate certain of the globs (e.g. .tex) with certain behavior (e.g. --no-c-escapes). I could imagine --deftexglob ".tex", but in addition to being a little gross, it'd get grosser if there turn out to be languages that need their own --no-c-escapes sort of switch. (The above script gets away with includeing README* in default globs, and *.tex in the latex globs only because there's no README.tex in tree.)
Thoughts?
I suppose the config approach seems cleaner. And it seems that it could provide a better solution for associating globs. Or if not better, at least it would hide away the complexity from the command line options.
You're closer to this use case, so I'll leave it up to you.
Is directory traversal a working feature in master branch of myint/scspell ? Perhaps not, since https://github.com/myint/scspell/pull/36 is not merged and has conflicts ...
@myint @dhruvsomani : Will this feature become functional in master?