Skip to content

Commit e0d7697

Browse files
committed
Print the url of the view, and add a verbose flag
1 parent 98266df commit e0d7697

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

q2cli/builtin/tools.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ def _merge_metadata(paths):
520520
type=click.Path(file_okay=True, dir_okay=False, readable=True))
521521
@click.option('--port', required=False, type=click.IntRange(1024, 65535),
522522
default=None, help='The port to serve the webapp on.')
523-
def view(result_path, port):
523+
@click.option('--verbose', is_flag=True,
524+
help='Display all GET requests in the terminal.')
525+
def view(result_path, port, verbose):
524526
# Guard headless envs from having to import anything large
525527
import sys
526528

@@ -556,6 +558,10 @@ def view(result_path, port):
556558
# Start server
557559
class Handler(http.server.SimpleHTTPRequestHandler):
558560
def do_GET(self):
561+
# Redirect the output from these requests to devnull if not verbose
562+
if not verbose:
563+
sys.stderr = open(os.devnull, 'w')
564+
559565
# Determine if this is a request for the file we are supposed to be
560566
# viewing
561567
if self.path == result_path:
@@ -624,8 +630,10 @@ def stop():
624630
thread.start()
625631

626632
# Open page on server
627-
launch_status = click.launch(
628-
f'http://localhost:{port}?file={result_path}&session={session}')
633+
url = f'http://localhost:{port}?file={result_path}&session={session}'
634+
launch_status = click.launch(url)
635+
click.echo('Your view should open in your default browser shortly. You '
636+
f'may open it manually at the URL: {url}')
629637

630638
# Yell if there was an error
631639
if launch_status != 0:

0 commit comments

Comments
 (0)