diff --git a/ppx/ppx.py b/ppx/ppx.py index 4413b24..5b72cb4 100644 --- a/ppx/ppx.py +++ b/ppx/ppx.py @@ -12,11 +12,9 @@ def get_parser(): """Parse the command line arguments""" - desc = f""" - ppx version {__version__}. Use this command line utility to download - files from the PRIDE and MassIVE proteomics repositories. The paths - to the downloaded files are written to stdout. - """ + desc = f"""Use this command line utility to download files from the PRIDE and MassIVE + proteomics repositories. The paths to the downloaded files are written to + stdout.""" epilog = "More documentation and examples at: https://ppx.readthedocs.io" parser = ArgumentParser(description=desc, epilog=epilog) @@ -55,6 +53,13 @@ def get_parser(): ), ) + parser.add_argument( + "-t", + "--timeout", + type=float, + help="The maximum amount of time to wait for a server response.", + ) + parser.add_argument( "-f", "--force", @@ -66,6 +71,13 @@ def get_parser(): ), ) + parser.add_argument( + "--version", + action="version", + help="Get the version of ppx.", + version="%(prog)s " + __version__, + ) + return parser @@ -77,7 +89,7 @@ def main(): parser = get_parser() args = parser.parse_args() - proj = find_project(args.identifier, args.local) + proj = find_project(args.identifier, args.local, timeout=args.timeout) remote_files = proj.remote_files() if len(args.files) > 0: diff --git a/tests/system_tests/test_cli.py b/tests/system_tests/test_cli.py index 24afb3a..6201b2b 100644 --- a/tests/system_tests/test_cli.py +++ b/tests/system_tests/test_cli.py @@ -12,7 +12,7 @@ def test_pride(tmp_path): """Test the CLI for pride""" out_dir = tmp_path / PXID - cmd = ["ppx", "-l", str(out_dir), PXID, "*.txt"] + cmd = ["ppx", "-l", str(out_dir), "-t", "10", PXID, "*.txt"] subprocess.run(cmd, check=True) print(list(out_dir.iterdir())) @@ -23,3 +23,8 @@ def test_massive(tmp_path): cmd = ["ppx", "-l", str(out_dir), MSVID, "*/statistics.tsv"] subprocess.run(cmd, check=True) assert (out_dir / "ccms_statistics" / "statistics.tsv").exists() + + +def test_version(tmp_path): + """Test ppx version""" + subprocess.run(["ppx", "--version"], check=True)