summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-05-28 16:52:43 +0600
committerArmin Ronacher <armin.ronacher@active-4.com>2014-05-28 16:52:43 +0600
commitc6872ec14c52f754dcfcca1475e2046fd0f92184 (patch)
treed4f5d0bc901b3cb917bf38b3e919b334723a7725 /examples
parent1ee30bbc8a3888c390a5ae308e366c6cf6a01178 (diff)
downloadclick-c6872ec14c52f754dcfcca1475e2046fd0f92184.tar.gz
Added more examples to termui
Diffstat (limited to 'examples')
-rw-r--r--examples/termui/termui.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/termui/termui.py b/examples/termui/termui.py
index 13bbf38..66d5bf5 100644
--- a/examples/termui/termui.py
+++ b/examples/termui/termui.py
@@ -71,6 +71,35 @@ def progress(count):
@cli.command()
+@click.argument('url')
+def open(url):
+ """Opens a file or URL In the default application."""
+ click.launch(url)
+
+
+@cli.command()
+@click.argument('url')
+def locate(url):
+ """Opens a file or URL In the default application."""
+ click.launch(url, locate=True)
+
+
+@cli.command()
+def edit():
+ """Opens an editor with some text in it."""
+ MARKER = '# Everything below is ignored\n'
+ message = click.edit('\n\n' + MARKER)
+ if message is not None:
+ msg = message.split(MARKER, 1)[0].rstrip('\n')
+ if not msg:
+ click.echo('Empty message!')
+ else:
+ click.echo('Message:\n' + msg)
+ else:
+ click.echo('You did not enter anything!')
+
+
+@cli.command()
def clear():
"""Clears the entire screen."""
click.clear()