6
6
import shlex
7
7
import sys
8
8
from abc import ABC , abstractmethod
9
- from collections .abc import Callable
9
+ from collections .abc import Callable , Iterable , Sequence
10
10
from dataclasses import dataclass
11
- from typing import Any , overload
11
+ from typing import Any , Protocol , overload
12
12
13
13
from unrealsdk import logging
14
14
from unrealsdk .commands import NEXT_LINE , add_command , has_command , remove_command
@@ -75,6 +75,26 @@ def _handle_cmd(self, line: str, cmd_len: int) -> None:
75
75
except SystemExit :
76
76
pass
77
77
78
+ @overload
79
+ def add_argument [T ](
80
+ self ,
81
+ * name_or_flags : str ,
82
+ action : str | type [argparse .Action ] = ...,
83
+ nargs : int | str | None = None ,
84
+ const : Any = ...,
85
+ default : Any = ...,
86
+ type : Callable [[str ], Any ] | argparse .FileType | str = ...,
87
+ choices : Iterable [T ] | None = ...,
88
+ required : bool = ...,
89
+ help : str | None = ...,
90
+ metavar : str | tuple [str , ...] | None = ...,
91
+ dest : str | None = ...,
92
+ version : str = ...,
93
+ ** kwargs : Any ,
94
+ ) -> argparse .Action : ...
95
+ @overload
96
+ def add_argument (self , * args : Any , ** kwargs : Any ) -> argparse .Action : ...
97
+
78
98
def add_argument (self , * args : Any , ** kwargs : Any ) -> argparse .Action :
79
99
"""Wrapper which forwards to the parser's add_argument method."""
80
100
return self .parser .add_argument (* args , ** kwargs )
@@ -84,6 +104,31 @@ def __call__(self, args: argparse.Namespace) -> None:
84
104
self .callback (args )
85
105
86
106
107
+ class _FormatterClass (Protocol ):
108
+ def __call__ (self , * , prog : str ) -> argparse .HelpFormatter : ...
109
+
110
+
111
+ @overload
112
+ def command (
113
+ cmd : str | None = None ,
114
+ splitter : ARGPARSE_SPLITTER = shlex .split ,
115
+ * ,
116
+ prog : str | None = None ,
117
+ usage : str | None = None ,
118
+ description : str | None = None ,
119
+ epilog : str | None = None ,
120
+ parents : Sequence [argparse .ArgumentParser ] = [],
121
+ formatter_class : _FormatterClass = ...,
122
+ prefix_chars : str = "-" ,
123
+ fromfile_prefix_chars : str | None = None ,
124
+ argument_default : Any = None ,
125
+ conflict_handler : str = "error" ,
126
+ add_help : bool = True ,
127
+ allow_abbrev : bool = True ,
128
+ exit_on_error : bool = True ,
129
+ ) -> Callable [[ARGPARSE_CALLBACK ], ArgParseCommand ]: ...
130
+
131
+
87
132
@overload
88
133
def command (
89
134
cmd : str | None = None ,
0 commit comments