cli coming together

This commit is contained in:
Kenneth Reitz
2011-09-24 14:41:13 -04:00
parent b8e214f78d
commit b0105565e2
+16 -3
View File
@@ -9,19 +9,24 @@ This module provides the command-line interface for Localtunnel.
import sys
import clint
from clint.arguments import _expand_path as expand_path
USAGE = """
USAGE = '''
Usage: localtunnel [options] <localport>
-k, --key FILE upload a public key for authentication
-h, --help show this help
""".lstrip()
'''.lstrip()
PORT_ERROR = 'Invalid port number.'
def display_usage():
"""Displays localtunnel usage."""
print USAGE
def display_port_error():
print PORT_ERROR
def main():
"""Main localtunnel dispatch."""
@@ -31,6 +36,8 @@ def main():
elif ('-k', '--key') in clint.args:
print 'importing key'
# print clint.args.files
print expand_path('~/ssh/*.pub')
sys.exit()
elif not len(clint.args.not_flags):
@@ -39,5 +46,11 @@ def main():
port = clint.args.not_flags.pop(0)
try:
int(port)
except ValueError:
display_port_error()
sys.exit(1)
if __name__ == '__main__':
main()