Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Point user to wiki article when there are no results
Browse files Browse the repository at this point in the history
The message is shown at most once per session. It is not shown in --json mode,
obviously.

Example:

    $ googler adjskfasdfhasjkfhsajkhdfa
    No results.
    If you believe this is a bug, please review https://git.io/googler-no-results before submitting a bug report.
    googler (? for help) asdfasdfhajsdfhasjkdfhajshdfahjdsk
    No results.
    googler (? for help)
  • Loading branch information
zmwangx committed Nov 16, 2019
1 parent a523c12 commit f0914da
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion googler
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,8 @@ class GooglerCmd(object):

self.promptcolor = True if os.getenv('DISABLE_PROMPT_COLOR') is None else False

self.no_results_instructions_shown = False

@property
def options(self):
"""Current options."""
Expand Down Expand Up @@ -2571,6 +2573,13 @@ class GooglerCmd(object):
for r in self.results:
self._urltable.update(r.urltable())

def warn_no_results(self):
printerr('No results.')
if not self.no_results_instructions_shown:
printerr('If you believe this is a bug, please review '
'https://git.io/googler-no-results before submitting a bug report.')
self.no_results_instructions_shown = True

@require_keywords
def display_results(self, prelude='\n', json_output=False):
"""Display results stored in ``self.results``.
Expand All @@ -2588,7 +2597,7 @@ class GooglerCmd(object):
else:
# Regular output
if not self.results:
print('No results.', file=sys.stderr)
self.warn_no_results()
else:
sys.stderr.write(prelude)
for r in self.results:
Expand Down

0 comments on commit f0914da

Please sign in to comment.