@@ -509,17 +509,24 @@ def conda_global_option():
509509 )
510510
511511
512- def required_tool_arg ():
512+ def required_tool_arg (allow_uris = False ):
513513 """ Decorate click method as requiring the path to a single tool.
514514 """
515- arg_type = click .Path (
515+ arg_type_class = click .Path if not allow_uris else UriLike
516+ arg_type = arg_type_class (
516517 exists = True ,
517518 file_okay = True ,
518519 dir_okay = False ,
519520 readable = True ,
520521 resolve_path = True ,
521522 )
522- return click .argument ("path" , metavar = "TOOL_PATH" , type = arg_type )
523+ if allow_uris :
524+ name = "uri"
525+ metavar = "TOOL_URI"
526+ else :
527+ name = "path"
528+ metavar = "TOOL_PATH"
529+ return click .argument (name , metavar = metavar , type = arg_type )
523530
524531
525532def required_job_arg ():
@@ -536,7 +543,7 @@ def required_job_arg():
536543
537544
538545def _optional_tools_default (ctx , param , value ):
539- if param .name == "paths" and len (value ) == 0 :
546+ if param .name in [ "paths" , "uris" ] and len (value ) == 0 :
540547 return [os .path .abspath (os .getcwd ())]
541548 else :
542549 return value
@@ -556,19 +563,32 @@ def optional_tools_or_packages_arg(multiple=False):
556563 )
557564
558565
559- def optional_tools_arg (multiple = False ):
566+ class UriLike (click .Path ):
567+
568+ def convert (self , value , param , ctx ):
569+ if "://" in value :
570+ return value
571+ else :
572+ return super (UriLike , self ).convert (value , param , ctx )
573+
574+
575+ def optional_tools_arg (multiple = False , allow_uris = False ):
560576 """ Decorate click method as optionally taking in the path to a tool
561577 or directory of tools. If no such argument is given the current working
562578 directory will be treated as a directory of tools.
563579 """
564- arg_type = click .Path (
580+ arg_type_class = click .Path if not allow_uris else UriLike
581+ arg_type = arg_type_class (
565582 exists = True ,
566583 file_okay = True ,
567584 dir_okay = True ,
568585 readable = True ,
569586 resolve_path = True ,
570587 )
571- name = "paths" if multiple else "path"
588+ if allow_uris :
589+ name = "uris" if multiple else "uri"
590+ else :
591+ name = "paths" if multiple else "path"
572592 nargs = - 1 if multiple else 1
573593 return click .argument (
574594 name ,
0 commit comments