Skip to content
Myr

Added more examples to termui

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 1ee30bb · Browse files · 2 files+34 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+34 added−0 removed

  • other:+34 added−0 removed

2 files+34 added−0 removed

modified:click/_termui_impl.py+5 added
395 unmodified lines
396 if wait:397 args.append('/WAIT')398 args.append(url)399 return subprocess.Popen(args).wait()400401 try:402 if locate:403 url = os.path.dirname(_unquote_file(url)) or '.'404 else:
2 unmodified lines
407 if wait:408 return c.wait()409 return 0410 except OSError:411 if url.startswith(('http://', 'https://')) and not locate and not wait:412 import webbrowser413 webbrowser.open(url)414 return 0415 return 1
modified:examples/termui/termui.py+29 added
69 unmodified lines
70 process_slowly(item)717273@cli.command()74@click.argument('url')75def open(url):76 """Opens a file or URL In the default application."""77 click.launch(url)787980@cli.command()81@click.argument('url')82def locate(url):83 """Opens a file or URL In the default application."""84 click.launch(url, locate=True)858687@cli.command()88def edit():89 """Opens an editor with some text in it."""90 MARKER = '# Everything below is ignored\n'91 message = click.edit('\n\n' + MARKER)92 if message is not None:93 msg = message.split(MARKER, 1)[0].rstrip('\n')94 if not msg:95 click.echo('Empty message!')96 else:97 click.echo('Message:\n' + msg)98 else:99 click.echo('You did not enter anything!')100101102@cli.command()103def clear():104 """Clears the entire screen."""105 click.clear()