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