From b0105565e218c5d20b48ba3677cb792cfb896ca1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 24 Sep 2011 14:41:13 -0400 Subject: [PATCH] cli coming together --- localtunnel/cli.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/localtunnel/cli.py b/localtunnel/cli.py index 70469ed..16b08ac 100644 --- a/localtunnel/cli.py +++ b/localtunnel/cli.py @@ -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] -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() \ No newline at end of file