main: split argument parser

This commit is contained in:
Roman Zeyde 2016-03-05 10:46:36 +02:00
parent c63201c90c
commit 1e86983782

View File

@ -26,21 +26,11 @@ def ssh_args(label):
return ['ssh'] + args + [identity['host']] return ['ssh'] + args + [identity['host']]
def create_agent_parser(): def create_parser():
"""Create argparse.ArgumentParser for this tool.""" """Create argparse.ArgumentParser for this tool."""
p = argparse.ArgumentParser() p = argparse.ArgumentParser()
p.add_argument('-v', '--verbose', default=0, action='count') p.add_argument('-v', '--verbose', default=0, action='count')
p.add_argument('identity', type=str, default=None,
help='proto://[user@]host[:port][/path]')
g = p.add_mutually_exclusive_group()
g.add_argument('-s', '--shell', default=False, action='store_true',
help='run ${SHELL} as subprocess under SSH agent')
g.add_argument('-c', '--connect', default=False, action='store_true',
help='connect to specified host via SSH')
g.add_argument('-g', '--git', default=False, action='store_true',
help='run git using specified identity as remote name')
curve_names = [name.decode('ascii') for name in formats.SUPPORTED_CURVES] curve_names = [name.decode('ascii') for name in formats.SUPPORTED_CURVES]
curve_names = ', '.join(sorted(curve_names)) curve_names = ', '.join(sorted(curve_names))
p.add_argument('-e', '--ecdsa-curve-name', metavar='CURVE', p.add_argument('-e', '--ecdsa-curve-name', metavar='CURVE',
@ -55,6 +45,20 @@ def create_agent_parser():
help='command to run under the SSH agent') help='command to run under the SSH agent')
return p return p
def create_agent_parser():
p = create_parser()
p.add_argument('identity', type=str, default=None,
help='proto://[user@]host[:port][/path]')
g = p.add_mutually_exclusive_group()
g.add_argument('-s', '--shell', default=False, action='store_true',
help='run ${SHELL} as subprocess under SSH agent')
g.add_argument('-c', '--connect', default=False, action='store_true',
help='connect to specified host via SSH')
g.add_argument('-g', '--git', default=False, action='store_true',
help='run git using specified identity as remote name')
return p
def setup_logging(verbosity): def setup_logging(verbosity):
"""Configure logging for this tool.""" """Configure logging for this tool."""