@@ -52,16 +52,15 @@ def build_parser() -> argparse.ArgumentParser:
5252 add_help = False , # Disable automatic help to add custom -help flag
5353 )
5454
55- # Mutually exclusive: -file or -list (one required)
56- group = parser .add_mutually_exclusive_group (required = True )
57- group .add_argument (
55+ parser .add_argument (
5856 "--file" ,
5957 "-file" ,
6058 dest = "file" ,
6159 metavar = "filename" ,
6260 help = "Provide a file to import. Must be in the CESM inputdata directory." ,
6361 )
64- group .add_argument (
62+
63+ parser .add_argument (
6564 "--list" ,
6665 "-list" ,
6766 dest = "filelist" ,
@@ -309,12 +308,11 @@ def print_can_file_be_downloaded(file_can_be_downloaded: bool):
309308def get_files_to_process (file : str , filelist : str ):
310309 """Get list of files to process.
311310
312- Uses either --file or --filelist. "Prefers" --file, but they're actually mutually exclusive, so
313- don't rely on that.
311+ Uses --file and/or --filelist arguments.
314312
315313 Args:
316314 file (str): Single file to process.
317- filelist (str): File containing list of files to process
315+ filelist (str): File containing list of files to process.
318316
319317 Returns:
320318 list: List of files to process
@@ -323,14 +321,22 @@ def get_files_to_process(file: str, filelist: str):
323321 if file is not None :
324322 files_to_process = [file ]
325323 else :
324+ files_to_process = []
325+
326+ if filelist is not None :
326327 list_path = Path (filelist ).expanduser ().resolve ()
327328 if not list_path .exists ():
328329 logger .error ("rimport: list file not found: %s" , list_path )
329330 return None , 2
330- files_to_process = read_filelist (list_path )
331- if not files_to_process :
331+ files_in_list = read_filelist (list_path )
332+ if not files_in_list :
332333 logger .error ("rimport: no filenames found in list: %s" , list_path )
333334 return None , 2
335+ files_to_process .extend (files_in_list )
336+
337+ if not files_to_process :
338+ logger .error ("rimport: At least one of --file or --filelist is required" )
339+ return None , 2
334340
335341 return files_to_process , 0
336342
0 commit comments