[Surfraw-devel] ANN: surfraw-tools 0.1.0, cli programs to generate elvi

Gabriel Lisaca gabriel.lisaca at gmail.com
Fri Jul 3 09:10:42 BST 2020


Hi, I wrote a program (`mkelvis`) to make writing elvi easier.  It's
available on PyPI [1] and licensed under Apache-2.0.  The only 
dependencies are (at least) Python 3.7 and Jinja2 (>=2.10), both of 
which are on Debian Stable FYI.

Features:

1. A selection of option *types*, which are checked at `mkelvis` 
definition-time and elvis runtime: bool (or yes-no), enum, anything, 
list, flag, alias; there's also "special" options, see next item.

2. Shortcuts to generate common options: `--use-results-option` to get 
`-results=NUM`, `--use-language-option` to get `-language=ISOCODE`--all 
of which take default values from the expected variables.

3. Map variables (which come from your options) to URL parameters (e.g., 
map `sort` to get `sort=$SORTVAL` in the query string); variable values 
are percent-encoded by default.

4. Inline variables to keywords in the search query (e.g., inline 
`filetype` to get `filetype:$FILETYPEVAL` appended to the query); 
variable values are double-quoted if it contains whitespace.

5. Abstract over exact values of query parameters using `--collapse=` to 
mutate variables in shell case-statements (`$_` is an alias to the 
current variable).  Allows providing a nicer interface to search engines.

6. No pathname expansion before calling `w3_url_of_arg` to allow '*' 
characters in query without spewing out contents of directories.

7. Elvi-specific tab-completions; uses my unmerged system for 
bash-completions [2]; use `--no-completions` to disable.

8. Control over some aspects of formatting: `--num-tabs=` to align 
description in `sr -elvi`, `--metavar=` and `--describe=` to set metavar 
and description for variables respectively.

9. Readable output elvi, with explanatory comments and templates. 
Allows one to generate elvi to hand-modify if needed.

The README.md provided with the package explains this in depth and 
`mkelvis --help` for missed stuff.  You can also check my elvi repo [3] 
that uses `mkelvis` to generate all of the elvi.  There are more exotic 
features I haven't documented yet: see `akllib` in my elvi repo for an 
example of this.

I plan to expand the collection of programs as the need arises. 
Contributions are welcome.  Check the repo's [4] issue tracker for more.

Cheers,
Gabriel

[1]: https://pypi.org/project/surfraw-tools/
[2]: https://gitlab.com/surfraw/Surfraw/-/merge_requests/15
[3]: https://github.com/Hoboneer/surfraw-elvis
[4]: https://github.com/Hoboneer/surfraw-elvis-generator



More information about the Surfraw-devel mailing list