From 8eba81723ac4e4a457ecc925d127c6266425685c Mon Sep 17 00:00:00 2001
From: Amandine PERRIN <amandine.perrin@pasteur.fr>
Date: Fri, 6 Nov 2020 15:18:59 +0100
Subject: [PATCH] warning if no species name nor output directory given

---
 PanACoTA/subcommands/prepare.py             | 5 +++--
 test/test_functional/test_prepare-parser.py | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/PanACoTA/subcommands/prepare.py b/PanACoTA/subcommands/prepare.py
index 9f4d221b..c791c6cc 100644
--- a/PanACoTA/subcommands/prepare.py
+++ b/PanACoTA/subcommands/prepare.py
@@ -476,8 +476,9 @@ def check_args(parser, args):
 
     # WARNINGS
     # User did not specify a species name
-    if not args.NCBI_species:
-        print(colored("WARNING: you did not provide a species name ('-s species' option'). "
+    if not args.NCBI_species and not args.outdir:
+        print(colored("WARNING: you did not provide a species name ('-s species' option') "
+            "nor an output directory ('-o outdir'). "
                       "All files will be downloaded in a folder called with the NCBI species "
                       f"taxid {args.NCBI_species_taxid} instead of the species name.", "yellow"))
     # If user wants to cut genomes, warn him to check that it is on purpose (because default is cut at each 5'N')
diff --git a/test/test_functional/test_prepare-parser.py b/test/test_functional/test_prepare-parser.py
index b0571710..58d11329 100644
--- a/test/test_functional/test_prepare-parser.py
+++ b/test/test_functional/test_prepare-parser.py
@@ -336,13 +336,14 @@ def test_parser_nospecies(capsys):
     """
     parser = argparse.ArgumentParser(description="Prepare", add_help=False)
     prepare.build_parser(parser)
-    options = prepare.parse(parser, "-t 1234 -o outdir".split())
+    options = prepare.parse(parser, "-t 1234".split())
     assert not options.no_refseq
     assert not options.only_mash
     assert options.NCBI_species_taxid == "1234"
     assert options.NCBI_species == ""
     out, err = capsys.readouterr()
-    assert ("WARNING: you did not provide a species name ('-s species' option'). "
+    assert ("WARNING: you did not provide a species name ('-s species' option') "
+            "nor an output directory ('-o outdir'). "
             "All files will be downloaded in a folder called with the NCBI species "
             "taxid 1234 instead of the species name.") in out
 
-- 
GitLab