Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_main_version(capsys):
with pytest.raises(SystemExit) as exit_e:
main(['--version'])
out, err = capsys.readouterr()
out = out.splitlines()
assert exit_e.value.code == 0
assert out[0] == tm.VERSION_STRING
assert not err
def do_version(self, cmdline: cmd2.Statement):
"""Show the version number of this program."""
self.parse_args(self.version_parser, cmdline.argv)
self.poutput(tm.VERSION_STRING)
quiet_help = 'suppress all status output'
parser.add_argument('-q', '--quiet',
action='store_true', help=quiet_help)
status_help = 'send status information to stdout instead of stderr'
parser.add_argument('-s', '--status-to-stdout',
action='store_true', help=status_help)
debug_help = 'show additional debugging information while processing commands'
parser.add_argument('-d', '--debug',
action='store_true', help=debug_help)
version_help = 'show the version information and exit'
parser.add_argument('-v', '--version', action='version',
version=tm.VERSION_STRING, help=version_help)
url_help = 'url of the tomcat manager web application'
parser.add_argument('manager_url', nargs='?',
help=url_help)
command_help = 'optional command to run, if no command given, enter an interactive shell'
parser.add_argument('command', nargs='?',
help=command_help)
arg_help = 'optional arguments for command'
parser.add_argument('command_args', nargs=argparse.REMAINDER,
help=arg_help)
return parser