431431from renku .core .commands .format .datasets import DATASETS_COLUMNS , DATASETS_FORMATS
432432
433433
434+ def _complete_datasets (ctx , param , incomplete ):
435+ from renku .core .commands .dataset import search_datasets
436+
437+ try :
438+ result = search_datasets ().build ().execute (name = incomplete )
439+ return result .output
440+ except Exception :
441+ return []
442+
443+
434444@click .group ()
435445def dataset ():
436446 """Dataset commands."""
@@ -508,7 +518,7 @@ def create(name, title, description, creators, metadata, keyword):
508518
509519
510520@dataset .command ()
511- @click .argument ("name" )
521+ @click .argument ("name" , shell_complete = _complete_datasets )
512522@click .option ("-t" , "--title" , default = None , type = click .STRING , help = "Title of the dataset." )
513523@click .option ("-d" , "--description" , default = None , type = click .STRING , help = "Dataset's description." )
514524@click .option (
@@ -570,7 +580,7 @@ def edit(name, title, description, creators, metadata, keyword):
570580
571581
572582@dataset .command ("show" )
573- @click .argument ("name" )
583+ @click .argument ("name" , shell_complete = _complete_datasets )
574584def show (name ):
575585 """Show metadata of a dataset."""
576586 from renku .core .commands .dataset import show_dataset
@@ -607,8 +617,8 @@ def show(name):
607617
608618
609619@dataset .command ()
610- @click .argument ("name" )
611- @click .argument ("urls" , nargs = - 1 )
620+ @click .argument ("name" , shell_complete = _complete_datasets )
621+ @click .argument ("urls" , type = click . Path (), nargs = - 1 )
612622@click .option ("-e" , "--external" , is_flag = True , help = "Creates a link to external data." )
613623@click .option ("--force" , is_flag = True , help = "Allow adding otherwise ignored files." )
614624@click .option ("-o" , "--overwrite" , is_flag = True , help = "Overwrite existing files." )
@@ -640,7 +650,7 @@ def add(name, urls, external, force, overwrite, create, sources, destination, re
640650
641651
642652@dataset .command ("ls-files" )
643- @click .argument ("names" , nargs = - 1 )
653+ @click .argument ("names" , nargs = - 1 , shell_complete = _complete_datasets )
644654@click .option (
645655 "--creators" ,
646656 help = "Filter files which where authored by specific creators. Multiple creators are specified by comma." ,
@@ -671,7 +681,7 @@ def ls_files(names, creators, include, exclude, format, columns):
671681
672682
673683@dataset .command ()
674- @click .argument ("name" )
684+ @click .argument ("name" , shell_complete = _complete_datasets )
675685@click .option ("-I" , "--include" , multiple = True , help = "Include files matching given pattern." )
676686@click .option ("-X" , "--exclude" , multiple = True , help = "Exclude files matching given pattern." )
677687@click .option ("-y" , "--yes" , is_flag = True , help = "Confirm unlinking of all files." )
@@ -695,7 +705,7 @@ def remove(name):
695705
696706
697707@dataset .command ("tag" )
698- @click .argument ("name" )
708+ @click .argument ("name" , shell_complete = _complete_datasets )
699709@click .argument ("tag" )
700710@click .option ("-d" , "--description" , default = "" , help = "A description for this tag" )
701711@click .option ("--force" , is_flag = True , help = "Allow overwriting existing tags." )
@@ -708,7 +718,7 @@ def tag(name, tag, description, force):
708718
709719
710720@dataset .command ("rm-tags" )
711- @click .argument ("name" )
721+ @click .argument ("name" , shell_complete = _complete_datasets )
712722@click .argument ("tags" , nargs = - 1 )
713723def remove_tags (name , tags ):
714724 """Remove tags from a dataset."""
@@ -719,7 +729,7 @@ def remove_tags(name, tags):
719729
720730
721731@dataset .command ("ls-tags" )
722- @click .argument ("name" )
732+ @click .argument ("name" , shell_complete = _complete_datasets )
723733@click .option ("--format" , type = click .Choice (DATASET_TAGS_FORMATS ), default = "tabular" , help = "Choose an output format." )
724734def ls_tags (name , format ):
725735 """List all tags of a dataset."""
@@ -776,7 +786,7 @@ def wrapper(f):
776786
777787
778788@dataset .command ("export" )
779- @click .argument ("name" )
789+ @click .argument ("name" , shell_complete = _complete_datasets )
780790@export_provider_argument ()
781791@click .option ("-p" , "--publish" , is_flag = True , help = "Automatically publish exported dataset." )
782792@click .option ("-t" , "--tag" , help = "Dataset tag to export" )
@@ -817,7 +827,7 @@ def import_(uri, name, extract, yes):
817827
818828
819829@dataset .command ("update" )
820- @click .argument ("names" , nargs = - 1 )
830+ @click .argument ("names" , nargs = - 1 , shell_complete = _complete_datasets )
821831@click .option (
822832 "--creators" ,
823833 help = "Filter files which where authored by specific creators. Multiple creators are specified by comma." ,
0 commit comments