hrs / docsim

A simple, fast command-line tool for searching and comparing text documents.

Repository from Github https://github.comhrs/docsimRepository from Github https://github.comhrs/docsim

Tweak command-line interface to take string query by default

hrs opened this issue · comments

When I started writing docsim I'd thought of it as a tool for comparing documents (hence document similarity). But I'd been thinking of "documents" as "files," not as abstract blobs of text including queries, so I added a --query flag that took a file, not a string.

Currently:

  • --query takes a path argument
  • passing in a string query only works through STDIN.

Ideally, we'd have something like:

  • the first positional argument is always a string query, unless either:
    • there's a Boolean --stdin flag (or something like -, mirroring its use in grep), in which case we read from STDIN, or
    • there's a string flag --file or --input (or even leave it at --query) that takes a file and acts in the current way.

The usage lines in the man page would look something like:

docsim [OPTION...] QUERY [PATH...]

command | docsim [OPTION...] --stdin [PATH...]

docsim [OPTION...] --file PATH [PATH...]