[PATCH 2/2] quest: Output errors and meta informations to stderr

Olly Betts olly at survex.com
Thu Nov 28 08:29:46 GMT 2019


Thanks for the patches.

On Thu, Nov 14, 2019 at 05:20:08PM +0100, Jerabek Vladimir wrote:
> ---
>  xapian-core/examples/quest.cc | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/xapian-core/examples/quest.cc b/xapian-core/examples/quest.cc
> index 9953861d8ce9..831d4a87c5cb 100644
> --- a/xapian-core/examples/quest.cc
> +++ b/xapian-core/examples/quest.cc
> @@ -398,14 +398,14 @@ try {
>      Xapian::Query query = parser.parse_query(argv[optind], flags);
>      const string & correction = parser.get_corrected_query_string();
>      if (!correction.empty())
> -	cout << "Did you mean: " << correction << "\n\n";
> +	cerr << "Did you mean: " << correction << "\n\n";
>  
>      if (!quiet) {
> -	cout << "Parsed Query: " << query.get_description() << endl;
> +	cerr << "Parsed Query: " << query.get_description() << endl;
>      }
>  
>      if (!have_database) {
> -	cout << "No database specified so not running the query." << endl;
> +	cerr << "No database specified so not running the query." << endl;

I'm concerned this makes quest harder to use as a tool for manually
trying out queries to debug problems, which is really its main purpose.

Splitting the output over stdout and stderr would mean you could no
longer just `quest ...|less` or `quest ... > quest.out`.  At least
extra tedious typing to redirect stderr to stdout would be needed,
but you probably also need to worry about the relative ordering due to
buffering.

I take it your main aim here is to have a machine readable output,
but there's a tension between supporting that and having a tool that's
easy for humans to use with output that can evolve with time.

I wonder if a separate tool which produces a machine readable format
with an actual specification would be a better approach to this?

If that's not it, what's the motivation behind these changes?

Cheers,
    Olly



More information about the Xapian-devel mailing list