From 1e869837827cb10d8b439259a2d5da75cb3b49cf Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 5 Mar 2016 10:46:36 +0200 Subject: [PATCH] main: split argument parser --- trezor_agent/__main__.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/trezor_agent/__main__.py b/trezor_agent/__main__.py index e3c4a55..30f2bbd 100644 --- a/trezor_agent/__main__.py +++ b/trezor_agent/__main__.py @@ -26,21 +26,11 @@ def ssh_args(label): return ['ssh'] + args + [identity['host']] -def create_agent_parser(): +def create_parser(): """Create argparse.ArgumentParser for this tool.""" p = argparse.ArgumentParser() 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 = ', '.join(sorted(curve_names)) 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') 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): """Configure logging for this tool."""