Skip to content

Commit 2710cfe

Browse files
authored
Merge pull request #1362 from common-workflow-language/argcomplete
Added argcomplete
2 parents 2cec4ee + 2d55b5d commit 2710cfe

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

cwltool/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
"""Entry point for cwltool."""
33

4+
import argcomplete
45
import argparse
56
import functools
67
import io
@@ -100,7 +101,7 @@
100101
windows_default_container_id,
101102
)
102103
from .workflow import Workflow
103-
104+
# PYTHON_ARGCOMPLETE_OK
104105

105106
def _terminate_processes() -> None:
106107
"""Kill all spawned processes.
@@ -396,7 +397,7 @@ def init_job_order(
396397
k: v for k, v in cmd_line.items() if k.startswith(record_name)
397398
}
398399
for key, value in record_items.items():
399-
record[key[len(record_name) + 1 :]] = value
400+
record[key[len(record_name) + 1:]] = value
400401
del cmd_line[key]
401402
cmd_line[str(record_name)] = record
402403
if "job_order" in cmd_line and cmd_line["job_order"]:
@@ -854,7 +855,9 @@ def main(
854855
addl = [] # type: List[str]
855856
if "CWLTOOL_OPTIONS" in os.environ:
856857
addl = os.environ["CWLTOOL_OPTIONS"].split(" ")
857-
args = arg_parser().parse_args(addl + argsl)
858+
parser = arg_parser()
859+
argcomplete.autocomplete(parser)
860+
args = parser.parse_args(addl + argsl)
858861
if args.record_container_id:
859862
if not args.cidfile_dir:
860863
args.cidfile_dir = os.getcwd()
@@ -895,7 +898,7 @@ def main(
895898
args.workflow = "CWLFile"
896899
else:
897900
_logger.error("CWL document required, no input file was provided")
898-
arg_parser().print_help()
901+
parser.print_help()
899902
return 1
900903
if args.relax_path_checks:
901904
command_line_tool.ACCEPTLIST_RE = command_line_tool.ACCEPTLIST_EN_RELAXED_RE

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"typing-extensions",
106106
"coloredlogs",
107107
"pydot >= 1.4.1",
108+
"argcomplete",
108109
],
109110
extras_require={
110111
"deps": ["galaxy-tool-util"],

typeshed/3/argcomplete/__init__.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Any, Optional
2+
import argparse
3+
class CompletionFinder:
4+
always_complete_options: Any = ...
5+
exclude: Any = ...
6+
validator: Any = ...
7+
print_suppressed: Any = ...
8+
completing: bool = ...
9+
default_completer: Any = ...
10+
append_space: Any = ...
11+
def __init__(self, argument_parser: Optional[argparse.ArgumentParser] = ..., always_complete_options: bool = ..., exclude: Optional[Any] = ..., validator: Optional[Any] = ..., print_suppressed: bool = ..., default_completer: Any = ..., append_space: Optional[Any] = ...) -> None: ...
12+
def __call__(self, argument_parser: argparse.ArgumentParser, always_complete_options: bool = ..., exit_method: Any = ..., output_stream: Optional[Any] = ..., exclude: Optional[Any] = ..., validator: Optional[Any] = ..., print_suppressed: bool = ..., append_space: Optional[Any] = ..., default_completer: Any = ...) -> None: ...
13+
def collect_completions(self, active_parsers: Any, parsed_args: Any, cword_prefix: Any, debug: Any): ...
14+
def filter_completions(self, completions: Any): ...
15+
def quote_completions(self, completions: Any, cword_prequote: Any, last_wordbreak_pos: Any): ...
16+
def rl_complete(self, text: Any, state: Any): ...
17+
def get_display_completions(self): ...
18+
19+
class ExclusiveCompletionFinder(CompletionFinder): ...
20+
21+
autocomplete: CompletionFinder
22+

0 commit comments

Comments
 (0)